-
Notifications
You must be signed in to change notification settings - Fork 33
Custom fields API #42
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
Conversation
Does the I know a lot of requestors, myself included, are wanting to surface additional database types, for example |
|
Waiting for this feature in order to adopt Strapi as headless cms, but we plan in many cases to use 'json' as base type. So will be extremely useful to extend the CustomFieldAdminOptions Interface with a value formatter function, and a value query function, in order to allow the custom Field to be exposed on the Listing View even if is of base type 'json' (or other types). es interface CustomFieldAdminOptions {
// The settings to extend in the Content Manager List View
decorators?: {
valueFormatter: (value: CMValue) => Promise<string> | string;
valueQuery: (value: CMValue, searchParams: CMSearchParams) => Promise<boolean> | boolean;
}
}If the interface does offer a proper way to formatting and query the base type value, |
@magick93 in this context, type refers to the Strapi type. They're pretty close to database types but a bit higher level. You can find the list there.
We're aware of this, and it's definitely something we'll want to add to Strapi. It's not the scope of this current feature however. We think of custom fields as a first step that already brings value, and that will later work hand in hand with custom types. |
@actarian that's interesting thanks for the insight. In think many others will be in that situtation, especially until we add custom database types. Regarding your suggested solution:
|
@remidej as per the current capabilities is not possible to add a field in the listing of type JSON, only few types are allowed. So the View component should not appear if referred to a base type JSON.
I'm aware of this issue, and is for this reason that I would allow at least the decision to add other non supported types in the listing to the developer, that should provide a custom implementation maybe of the query?. But I understand that the best solution would be to resolve that issue on the database layer. |
As a sub-comment to this, while it's not directly supported and largely still extremely unstable. You could potentially bypass this requirement here: https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#database-validations-and-settings |
|
Hi and thank you for this very detailed RFC, this looks promising. I'm sharing some thoughts I have regarding the server implementation: I would like to better understand the reasoning behind exposing a "field" notion on the server logic, whereas the only additional logic done is handled by the admin panel.
And a potential drawback would be the implementation:
I'm really looking for counter-arguments here because I feel like I might be missing something from the reasoning behind the server implementation. Note: If we continue with this "customField" notion in the server, maybe we could at least put the registry in the admin services as it would be an admin-related feature, what do you think? (smth like |
Add options object to custom field attributes
|
Hey @Convly, sorry for not responding earlier. So far, it's true that custom fields are very admin-oriented, so I understand your concern. But there are 2 reasons why we thought we'd register custom fields on the server too. Backend validationFirst, though it won't be part of the MVP, we'll later want to enable custom fields to add their validation rules on the server. For example, if your custom field uses the Type swappingThe second reason is about the But when it comes to the frontend, So to follow the example mentioned in the RFC, when this is stored in your schema.json: {
"attributes": {
"attributeName": {
"type": "customField",
"customField": "plugin::plugin-name.fieldname"
}
}
}The admin on the other hand would receive this: {
"attributes": {
"attributeName": {
"type": "string",
"customField": "plugin::plugin-name.fieldname"
}
}
}The exact format after transformation is not determined yet, but the idea is that the admin would be able to infer that it's a custom type even without the explicit type. To do this transformation, we need to map the original attribute to the type it's using, and it needs to happen on the server. That requires having some sort of custom fields store on the backend, which is why we think we need the server registration. Regarding your suggestion to use something like |
|
Will it be available in v4.2? |
No, release date TBD |
|
Any updates on the progress here? Would be great to have an estimate on the release |
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.
🚀
|
Thanks for all your feedback! We're merging the RFC because we're committing to that API. Development will now happen on this branch in the strapi repo. We expect to ship a beta release for custom fields in September (ping @Landstein) |
|
This pull request has been mentioned on Strapi Community Forum. There might be relevant details there: |




This PR introduces a proposal for the custom fields API (view the formatted RFC here).
It is a follow-up to the non-technical custom fields RFC previously published.
Please, share your feedback and ideas 🙂
Co-authored by @markkaylor @remidej @soupette