[bug]: Custom Field requires type: json in schema to save data
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- full-stack
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 24
- フォーク
- 13
- 平均マージ
- 5日 3時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
strapi/sdk-plugin のほかの issue
-
難易度 4/5 半日 初心者へのやさしさ 15/100
strapi/sdk-plugin#244 ·
メンテナーはふだん 6 日以内に返信
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" plugins対応中かも @unrevised6419 が 44 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
strapi/sdk-plugin#242 ·
メンテナーはふだん 6 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
strapi/sdk-plugin#241 ·
メンテナーはふだん 6 日以内に返信
-
[feat]: build a subset of bundles with --bundle, for per-bundle task caching対応中かも @unrevised6419 が 51 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
strapi/sdk-plugin#238 ·
メンテナーはふだん 6 日以内に返信
-
[bug]: When building with latest sdk-plugin version, I loose sub folders types再び着手できるかも @jhoward1994 が 247 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンissue: bug
strapi/sdk-plugin#115 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 6 日以内に返信
strapi/sdk-plugin の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AykutSarac/jsoncrack.com#616 ·
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtag対応中かも @bardrop が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
nbd-wtf/nostr-tools#578 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
backnotprop/plannotator#3427 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/Power-CAT-Copilot-Studio-Kit#942 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pageオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AOSSIE-Org/DebateAI#801 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信