-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Bug report
Describe the bug
In Strapi 3 it is possible to declare a custom field within a content-type schema and have it link to a custom component for data entry using what is essentially undocumented functionality. In order to do this, we need to update the attributes within schema.json to include a columnType like so:
"attributes": {
"Title": {
"type": "string",
"required": true
},
"Video Stream": {
"type": "videostream",
"columnType": "text"
}
}
This allows the component attached to the videostream type to store data in a DB column matching columnType.
In Strapi 3, we are still able to attach a custom component to a custom field, using the addFields method within the register method of a plugin:
app.addFields({ type: "videostream", Component: VideoStream });
However, adding the columnType to schema.json no longer creates the relevant column in the DB table for a content type, which means a custom field can no longer store or retrieve data for said content type. I suspect this is due to the addition of Yup schema validation under the hood.
Steps to reproduce the behavior
- Add a custom field via a plugin, using
app.addFields()within theregister(app)method. - Reference the custom field in the attributes section in
schema.jsonfor a content type. - The custom component will be rendered for the field in the content manager.
- When data is saved or attempted to load from an existing entry, it will fail.
Expected behavior
There should be some method to allow storage as a standard DB-ready data type.
In my case, I simply want to save a UUID from a custom menu drop-down that renders thumbnails for a list of video streams.
I appreciate this is essentially an undocumented feature, but it has broken a large number of plugins developed within the community. This includes the Color Picker plugin tutorial that is often referenced for documentation: https://www.paulgaumer.com/blog/how-to-create-a-color-picker-plugin-for-strapi-cms
Am happy to work on a PR to fix the issue if someone can give me some pointers around the integration of Yup and how the creation of DB tables works during startup.
System
- Node.js version: v16
- Yarn version: Classic
- Strapi version: v4.0.3
- Database: MySQL
- Operating system: Docker hosted Alpine linux