[bug]: Custom Field requires type: json in schema to save data
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- full-stack
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 24
- Fork
- 13
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của strapi/sdk-plugin
-
Độ khó 4/5 Nửa ngày Mức phù hợp với người mới 15/100
strapi/sdk-plugin#244 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsCó thể đã có người làm @unrevised6419 đã nhận 44 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
strapi/sdk-plugin#242 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
strapi/sdk-plugin#241 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingCó thể đã có người làm @unrevised6419 đã nhận 52 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
strapi/sdk-plugin#238 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesCó thể làm lại được @jhoward1994 đã nhận 248 ngày trước và không có pull request nào đang mở. Đang mởissue: bug
strapi/sdk-plugin#115 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của strapi/sdk-plugin
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AykutSarac/jsoncrack.com#616 ·
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtagCó thể đã có người làm @bardrop đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
nbd-wtf/nostr-tools#578 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
backnotprop/plannotator#3427 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/Power-CAT-Copilot-Studio-Kit#942 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pageĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AOSSIE-Org/DebateAI#801 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày