[bug]: Custom Field requires type: json in schema to save data
I maintainer di solito rispondono entro 6 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- full-stack
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 24
- Fork
- 13
- Merge medio
- 5g 3h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di strapi/sdk-plugin
-
Difficoltà 4/5 Mezza giornata Idoneità per principianti 15/100
strapi/sdk-plugin#244 ·
I maintainer di solito rispondono entro 6 giorni
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsForse già presa @unrevised6419 l’ha presa 43 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
strapi/sdk-plugin#242 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
strapi/sdk-plugin#241 ·
I maintainer di solito rispondono entro 6 giorni
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingForse già presa @unrevised6419 l’ha presa 51 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
strapi/sdk-plugin#238 ·
I maintainer di solito rispondono entro 6 giorni
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesForse di nuovo libera @jhoward1994 l’ha presa 247 giorni fa e non c’è nessuna pull request aperta. Apertaissue: bug
strapi/sdk-plugin#115 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di strapi/sdk-plugin
Issue simili
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pageApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AOSSIE-Org/DebateAI#801 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
ci: repo has no GitHub Actions workflow, so pushes and pull requests are never built or testedApertaagents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Add: BOM CineApertaapproved check:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno