Skip to content

Commit 0ea50df

Browse files
pwizlastb13579markkaylor
authored
Custom Fields (#1038)
* Bump version number (alpha) * Fix code block ending * Custom Fields - User Guide: All updates (#1039) * Keep old version number for now * Fix rendering issue caused by missing blank line after code block * [WIP] Custom Fields: Updates to Content-Type Builder documentation (#1018) * Add custom fields h2 * Replace field selection screenshot * Update "Configuring fields for content-types" * Add TODO for possible "managing custom fields" content * Reword marketplace mention and fix link * Fix rendering issue caused by missing blank line after code block * Delete deprecated comments * Mention custom fields in the Content Manager (#1051) * Update version number * Delete TODO as link now works * Mention custom fields in plugins introduction * Mention that custom fields can also be added to components * Update "Installing plugins via Marketplace" with custom fields * Mention custom fields in Global settings * Clean up completed TODOs * Exclude non-related content * Fix email closing (not-related to CF) * Update wording (removing "all") * Treat custom fields as part of plugins * Update description for "other plugins" settings * Revert screenshot change No custom fields tab in in-app Marketplace * Remove unused screenshot for "custom fields" settings * Fix what → which Co-authored-by: Shaun Brown <[email protected]> * Fix: filling up → filling out * Update built-in → pre-installed Co-authored-by: Shaun Brown <[email protected]> * Custom Fields - Dev docs: All updates (#1036) * Add custom fields to TOC * Fix unclosed array in TOC config * Prepare TOC for upcoming content * Custom fields - Dev docs: Add a new Development > Custom Fields page (#1035) * WIP * Add WIP reference and example guide for custom fields * Delete old file, now splitted into reference and guide * Improve reference guide * Add first draft of color picker custom fields guide * Improve reference documentation * Improve example guide * Mention custom fields in plugins development * Fix TOC casing * Remove tutorial and update sidebar and "main" doc file name * Temporarily remove callout for tutorial * Improve custom fields reference documentation * Further improve custom fields reference documentation * Update first note with a mention to app-specific custom fields * Add prerequisites (plugin) * Update `items` table * Add multimarkdown support + prepare for documenting all settings fields * Improve introduction * Improve `plugin` key description * Delete deprecated TODOs * Fix paths in example code * Update wording: settings → options * Improve `options` table * Update prerequisites to also mention enabling plugin * Remove callout from plugins dev, will be moved to another PR * Reword introduction sentence Co-authored-by: markkaylor <[email protected]> * Reword models attributes intro. description Co-authored-by: markkaylor <[email protected]> * Fix preposition and singular usage Co-authored-by: markkaylor <[email protected]> * Update text → string in color picker example * Mention `media` can't be used as a data type * Add `media` to the list of forbidden data types * Update validator code example Co-authored-by: markkaylor <[email protected]> * Remove question comment about inline components * Update string → text * Remove View component * Finish removing View component and update "Components" section * Improve mention of non-usable data types * Remove bootstrap() and mention src/admin/app.s * Add link to user guide + mention CF can be added to components * Remove some comments * Replace bootstrap() with register() * Mention yup * Improve settings items description * Remove note about not being able to import custom input components * Improve `options` description and code example * Fix user guide link (no #) * Update schema.json → schema * Remove non-relevant TODO * Update strapi code base links * Don't mention what happens if `plugin` is omitted in server * Simplify callouts * Fix CTB spelling Co-authored-by: Shaun Brown <[email protected]> * Move note about forbidden data types into the table * Fix 'can not' → 'cannot' * Fix: can't → cannot * Add tip for `Input` component props Co-authored-by: markkaylor <[email protected]> Co-authored-by: Shaun Brown <[email protected]> * Custom fields - Dev docs: Updates to Backend customization > Models (#1052) * Add a few draft lines about impact on models * Add custom fields section to models attributes docs * Add custom fields to the list of types availables in schema.json * Fix typo in customField parameter name * Replace `custom field` by `customField` in table * Fix uid for global field name * Fix gerundive Co-authored-by: Shaun Brown <[email protected]> * Improve description of plugin/global uids * Fix duplicate content Co-authored-by: Shaun Brown <[email protected]> * Custom fields - Dev docs: Minor updates and cross-links (#1053) * Mention custom fields in server and admin panel APIs for plugins * Mention custom fields in plugins development * Mention custom fields in the global register() and bootstrap() methods * Register a custom field in admin with register(), not bootstrap() * Add registering admin panel part of a CF to available actions * Fix: custom fields are registered in register(), not bootstrap() * Improve intro. sentence for bootstrap() Co-authored-by: markkaylor <[email protected]> Co-authored-by: Shaun Brown <[email protected]> * Remove multimarkdown plugin * Remove markdown-it dependency * Fix broken link * Add tip about publishing a plugin on npm * Update version number Co-authored-by: Shaun Brown <[email protected]> Co-authored-by: markkaylor <[email protected]>
1 parent c9d32f8 commit 0ea50df

File tree

16 files changed

+422
-12
lines changed

16 files changed

+422
-12
lines changed

docs/.vuepress/config/sidebar-developer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ const developer = [
214214
['/developer-docs/latest/development/admin-customization', 'Admin panel customization'],
215215
['/developer-docs/latest/development/plugins-extension.md', 'Plugins extension'],
216216
['/developer-docs/latest/development/plugins-development.md', 'Plugins development'],
217+
['/developer-docs/latest/development/custom-fields.md', 'Custom fields'],
217218
['/developer-docs/latest/development/typescript.md', 'TypeScript'],
218219
['/developer-docs/latest/development/providers.md', 'Providers'],
219220
],

docs/developer-docs/latest/developer-resources/plugin-api-reference/admin-panel.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Within the register function, a plugin can:
4949
* [create a new settings section](#createsettingsection)
5050
* define [injection zones](#injection-zones-api)
5151
* [add reducers](#reducers-api)
52+
* register the admin panel part of [custom fields](/developer-docs/latest/development/custom-fields.md#registering-a-custom-field-in-the-admin-panel)
5253

5354
#### registerPlugin()
5455

@@ -180,6 +181,7 @@ The Admin Panel API allows a plugin to take advantage of several small APIs to p
180181
| Declare an injection zone | [Injection Zones API](#injection-zones-api) | [`registerPlugin()`](#registerplugin) | [`register()`](#register) |
181182
| Add a reducer | [Reducers API](#reducers-api) | [`addReducers()`](#reducers-api) | [`register()`](#register) |
182183
| Create a hook | [Hooks API](#hooks-api) | [`createHook()`](#hooks-api) | [`register()`](#register) |
184+
| Register the admin panel part of a custom field | APIs for custom fields (see [custom fields documentation](/developer-docs/latest/development/custom-fields.md)) | `app.customFields.register()` | `register()` |
183185
| Add a single link to a settings section | [Settings API](#settings-api) | [`addSettingsLink()`](#addsettingslink) | [`bootstrap()`](#bootstrap) |
184186
| Add multiple links to a settings section | [Settings API](#settings-api) | [`addSettingsLinks()`](#addsettingslinks) | [`bootstrap()`](#bootstrap) |
185187
| Inject a Component in an injection zone | [Injection Zones API](#injection-zones-api) | [`injectComponent()`](#injection-zones-api) | [`bootstrap()`](#register) |

docs/developer-docs/latest/developer-resources/plugin-api-reference/server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To tap into the Server API, create a `strapi-server.js` file at the root of the
2828

2929
### register()
3030

31-
This function is called to load the plugin, even before the application is actually [bootstrapped](#bootstrap), in order to register [permissions](/developer-docs/latest/plugins/users-permissions.md) or database migrations.
31+
This function is called to load the plugin, before the application is [bootstrapped](#bootstrap), in order to register [permissions](/developer-docs/latest/plugins/users-permissions.md), the server part of [custom fields](/developer-docs/latest/development/custom-fields.md#registering-a-custom-field-on-the-server), or database migrations.
3232

3333
**Type**: `Function`
3434

docs/developer-docs/latest/development/backend-customization/models.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ Many types of attributes are available:
104104

105105
- scalar types (e.g. strings, dates, numbers, booleans, etc.),
106106
- Strapi-specific types, such as:
107-
- `media`, for files uploaded through the [Media library](/user-docs/latest/content-types-builder/configuring-fields-content-type.md#media)
107+
- `media` for files uploaded through the [Media library](/user-docs/latest/content-types-builder/configuring-fields-content-type.md#media)
108108
- `relation` to describe a [relation](#relations) between content-types
109+
- `customField` to describe [custom fields](#custom-fields) and their specific keys
109110
- `component` to define a [component](#components-2) (i.e. a data structure usable in multiple content-types)
110111
- `dynamiczone` to define a [dynamic zone](#dynamic-zones) (i.e. a flexible space based on a list of components)
111112
- and the `locale` and `localizations` types, only used by the [Internationalization (i18n) plugin](/developer-docs/latest/plugins/i18n.md)
@@ -118,7 +119,7 @@ The `type` parameter of an attribute should be one of the following values:
118119
| Date types | <ul><li>`date`</li> <li>`time`</li> <li>`datetime`</li> <li>`timestamp`</li></ul> |
119120
| Number types | <ul><li>`integer`</li><li>`biginteger`</li><li>`float`</li> <li>`decimal`</li></ul> |
120121
| Other generic types |<ul><li>`boolean`</li><li>`array`</li><li>`json`</li></ul> |
121-
| Special types unique to Strapi |<ul><li>`media`</li><li>[`relation`<Fa-Link color="grey" size="1x"/>](#relations)</li><li>[`component`<Fa-Link color="grey" size="1x"/>](#components)</li><li>[`dynamiczone`<Fa-Link color="grey" size="1x"/>](#dynamic-zones)</li></ul> |
122+
| Special types unique to Strapi |<ul><li>`media`</li><li>[`relation`<Fa-Link color="grey" size="1x"/>](#relations)</li><li>[`customField`<Fa-Link color="grey" size="1x"/>](#custom-fields)</li><li>[`component`<Fa-Link color="grey" size="1x"/>](#components)</li><li>[`dynamiczone`<Fa-Link color="grey" size="1x"/>](#dynamic-zones)</li></ul> |
122123
| Internationalization (i18n)-related types<br /><br />_Can only be used if the [i18n plugin](/developer-docs/latest/plugins/i18n.md) is installed_|<ul><li>`locale`</li><li>`localizations`</li></ul> |
123124

124125
#### Validations
@@ -494,6 +495,35 @@ The `tableName` key defines the name of the join table. It has to be specified o
494495

495496
:::::
496497

498+
#### Custom fields
499+
500+
[Custom fields](/developer-docs/latest/development/custom-field.md) extend Strapi’s capabilities by adding new types of fields to content-types. Custom fields are explicitly defined in the [attributes](#model-attributes) of a model with `type: customField`.
501+
Custom fields' attributes also accept:
502+
503+
Custom fields' attributes also show the following specificities:
504+
- a `customField` attribute whose value acts as a unique identifier to indicate which registered custom field should be used. Its value follows:
505+
- either the `plugin::plugin-name.field-name` format if a plugin created the custom field
506+
- or the `global::field-name` format for a custom field specific to the current Strapi application
507+
- and additional parameters depending on what has been defined when registering the custom field (see [custom fields documentation](/developer-docs/latest/development/custom-fields.md)).
508+
509+
```json
510+
// path: ./src/api/[apiName]/[content-type-name]/content-types/schema.json
511+
512+
{
513+
// …
514+
"attributes": {
515+
"attributeName": { // attributeName would be replaced by the actual attribute name
516+
"type": "customField",
517+
"customField": "plugin::color-picker.color",
518+
"options": {
519+
"format": "hex"
520+
}
521+
}
522+
}
523+
// …
524+
}
525+
```
526+
497527
#### Components
498528

499529
Component fields create a relation between a content-type and a component structure. Components are explicitly defined in the [attributes](#model-attributes) of a model with `type: 'component'` and accept the following additional parameters:

0 commit comments

Comments
 (0)