-
Notifications
You must be signed in to change notification settings - Fork 33
Custom fields #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Custom fields #40
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| - Start Date: 03-16-2022 | ||
| - RFC PR: (leave this empty) | ||
|
|
||
| _Disclaimer_: This RFC is at an early stage and covers only high-level requirements. We are hoping the community can help us identify and spec the technical requirements. Thank you in advance for your help. | ||
|
|
||
| # Summary | ||
|
|
||
| Custom fields are a way to extend Strapi’s capabilities. They allow users to add new fields to content types for a better content edition experience (nicer display, enriched data, more actions, etc). | ||
|
|
||
| # Examples | ||
|
|
||
| Based on all the input we got from the community, we identified a few key use cases we’d like to focus on first: | ||
|
|
||
| ### Map | ||
|
|
||
| A content editor could directly search for a location on a map. Instead of entering latitude and longitude coordinates. | ||
|
|
||
| ### Videos | ||
|
|
||
| Embedding a Youtube video would display a nice preview, which would make it easier to parse the content on a glimpse. Instead of having to click on the link to see what the video is about. | ||
|
|
||
| ### Color picker | ||
|
|
||
| Select any color in any format (HEX, RGB, CMYK) directly in Strapi. | ||
|
|
||
| ### URL | ||
|
|
||
| Fetch the data from a URL to show the favicon of the page, as well as the title. Instead of plain text. | ||
|
|
||
| ### Ecommerce | ||
|
|
||
| A more complex is the one where a field would fetch external data. Products from a BigCommerce store for instance. And directly display them in the Content Manager. | ||
|
|
||
| # Motivation | ||
|
|
||
| Being and staying the most customizable CMS is our goal. Fields are no exception. | ||
|
|
||
| Strapi currently supports 10 fields (excluding the dynamic zones and components). However, the possibilities of field types are endless. To empower the community to solve their use cases, we want to offer full autonomy to the fields needed by enabling new API capabilities on the front-end and back-end sides. | ||
|
|
||
| The content edition is at the core of Strapi’s value. Managing entries should be as natural as possible. Sometimes, it doesn’t work as well when you try to shoehorn something that doesn’t feel intuitive. For instance, entering a URL for a video. | ||
|
|
||
| At a later stage, we would also like to solve more advanced use cases, or even rethink some fundamental features such as the Components and Dynamic Zones for more customizations. | ||
|
|
||
| # Detailed design | ||
|
|
||
|  | ||
|
|
||
| There are 3 main areas impacted by this feature: | ||
|
|
||
| ### 1. Strapi Market & Settings | ||
|
|
||
| The first step is for a user to install the field. We are still debating on how custom fields should be installed in Strapi. Via a plugin or through a field package. | ||
|
|
||
| In any case, the next step is to configure the field if need be. Entering API keys for Google Maps or Shopify, for instance. | ||
|
|
||
| ### 2. Content-Type Builder | ||
|
|
||
|  | ||
|
|
||
| Once done, the custom field is available in the “custom” tab of the fields picker modal in the Content-Type Builder. | ||
|
|
||
| The configuration flow for a custom field should be the same as the native ones. An injection zone allows custom settings to be added in the “Advanced Settings” tab. | ||
|
|
||
| Note: the custom field badge is a combination of color and icon provided in the Design System. | ||
|
|
||
|  | ||
|
|
||
| Since we are not introducing any new field type, the content type schema won’t change in structure. This also means the custom fields have the same options as the native ones (ex: required, unique, etc), as well as some additional validation rules. | ||
|
|
||
| ### 3. Content Manager | ||
|
|
||
|  | ||
|
|
||
| Once properly set up, the real magic happens in the Content Manager. Instead of seeing the usual text fields, you can now interact with maps, videos, color pickers, etc. | ||
|
|
||
| In addition, the list view could support these new fields by displaying the field information in a different format than text. For instance, having a color indicator for the color picker column. | ||
|
|
||
| Currently, we still need to find solutions around the search, filtering, and sorting of custom fields. As much as it might not be critical to sort colors, it might be useful to filter the latest 30 product descriptions of all the products cheaper than $100 and in the Collection T-Shirt coming from a Shopify store for instance. | ||
|
|
||
| In any case, these actions will be based on the underlying type of the custom field. For instance, if the map field is stored as a String, there will be some limitations. | ||
|
|
||
| # Tradeoffs | ||
|
|
||
| ### Installation package: Plugin vs stand-alone package | ||
|
|
||
| As a **Plugin**: would fit perfectly in the current marketplace and review process with minor changes. | ||
|
|
||
| As a **Field package**: clearly separates the plugin purpose from the field. However, it could be listed as a dependency on the plugins. It means an Ecommerce plugin could add additional features, collection types and fields. | ||
|
|
||
| ### Field types | ||
|
|
||
| Currently, the plan is to only allow custom fields based on existing types (String, Number, JSON, etc.). However, we are considering adding more field types (ex: GeoJSON) at a later stage to support even more advanced custom fields. | ||
|
|
||
| Thank you very much for your reading, we are looking forward to reviewing your PR to make this feature a reality very soon. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what you mean by
as well as some additional validation rules?Are you referring to validations in the content type builder in order to save a custom field or adding custom validations for a custom field in the content manager?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter. For instance, insuring that a URL for a video is actually from Youtube in the case of a video embed. Or validating that a string is a URL, etc. Is it clearer?