[bug]: Custom Field requires type: json in schema to save data
Maintainers usually reply within 6 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- full-stack
Research direction
Start with the custom-field registration example in /admin/src/index.js and compare it with the official custom-fields documentation linked in the issue. Trace how the registered type and the generated schema affect persistence, then determine whether the fix belongs in the SDK behavior or the documentation. Done means complex custom-field data persists correctly or the required json configuration is clearly documented.
Written by the indexing model from the issue text.
Description
What version of @strapi/sdk-plugin are you using?
- Npm version: 10.8.2
- Node.js version: 20.18.3
- React version: 18.3.1
- Strapi version: 5.23.3
- @strapi/sdk-plugin version: 5.3.2
- Browser: Chrome
What's Wrong?
When using a custom field from any plugin in a content type schema, if the field is defined as:
"myCustomField": {
"type": "customField",
"customField": "plugin::<plugin-name>.<custom-field-name>"
}
Strapi does not save the data unless the field type is changed to "json":
"myCustomField": {
"type": "json",
"customField": "plugin::<plugin-name>.<custom-field-name>"
}
This is not documented and causes confusion, since the admin panel recognizes the custom field, but the data is not persisted unless the type is set to json.
To Reproduce
-
Create a content type with a custom field using a local plugin built with the Strapi SDK (e.g.
<plugin-name>), where the custom field is registered as typejsonin the plugin registration. -
Add the custom field from the Content-Type Builder to any collection type.
-
In the schema, define the field as:
"myCustomField": { "type": "customField", "customField": "plugin::<plugin-name>.<custom-field-name>" } -
Go to the admin panel and try to save data using the custom field.
-
Observe that the data is not saved/persisted.
-
Change the field type to
"json":"myCustomField": { "type": "json", "customField": "plugin::<plugin-name>.<custom-field-name>" } -
Now, data is saved correctly.
Expected Behaviour
Actual Behaviour
- The admin panel recognizes the custom field and allows input, but Strapi does not persist the data unless the type is set to
json. - This behaviour is not documented in the official docs, which show examples using
type: "customField".
Expected Behaviour
- Strapi should either:
- Handle custom fields that store arrays/objects without requiring manual change to
"json", or - Document this requirement clearly for custom field plugin authors and users.
- Handle custom fields that store arrays/objects without requiring manual change to
Technical Comparison with Official Documentation
- Official docs show custom fields defined as:
"color": {
"type": "customField",
"customField": "plugin::color-picker.color",
"options": {
"format": "hex"
}
}
- In practice, for custom fields that store complex data (arrays/objects), the type must be set to
jsonfor persistence:
"customFieldExample": {
"type": "json",
"customField": "plugin::<plugin-name>.<custom-field-name>"
}
- If
type: "customField"is used, the data is not saved.
Custom Field Registration
File: <plugin-path>/admin/src/index.js
app.customFields.register({
name: '<custom-field-name>',
pluginId: '<plugin-name>',
type: 'json', // Required for metadata persistence
intlLabel: {
id: '<plugin-name>.<custom-field-name>.label',
defaultMessage: '<custom-field-name>',
},
intlDescription: {
id: '<plugin-name>.<custom-field-name>.description',
defaultMessage: 'Select any asset',
},
components: {
Input: async () =>
import('./components/Input/Input').then((module) => ({
default: module.Input,
})),
},
options: {
// declare options here
},
});
- The custom field must use
type: 'json'for Strapi to persist complex data (arrays/objects). - If
type: 'customField'is used, data is not saved.
- Dominant language
- TypeScript
- Stars
- 24
- Forks
- 13
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from strapi/sdk-plugin
-
Difficulty 4/5 Half a day Newbie friendliness 15/100
strapi/sdk-plugin#244 ·
Maintainers usually reply within 6 days
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsPossibly taken @unrevised6419 claimed this 43 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
strapi/sdk-plugin#242 ·
Maintainers usually reply within 6 days
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
strapi/sdk-plugin#241 ·
Maintainers usually reply within 6 days
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingPossibly taken @unrevised6419 claimed this 51 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
strapi/sdk-plugin#238 ·
Maintainers usually reply within 6 days
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesMay be free again @jhoward1994 claimed this 247 days ago, and no pull request is open. Openissue: bug
strapi/sdk-plugin#115 · 2 comments · 1 assignee ·
Maintainers usually reply within 6 days
All issues in strapi/sdk-plugin
Similar issues
-
Add: BOM CineOpenapproved check:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug platform-android
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Termix-SSH/Mobile#146 · 1 comment ·
Maintainers usually reply within 2 days
-
MCP mcp-feedback-pattern
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/toolkit#2276 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
devswha/herdr-web-ui#3875 ·