Skip to content

Commit

Permalink
Custom Fields (#1038)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Aug 25, 2022
1 parent c9d32f8 commit 0ea50df
Show file tree
Hide file tree
Showing 16 changed files with 422 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/config/sidebar-developer.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ const developer = [
['/developer-docs/latest/development/admin-customization', 'Admin panel customization'],
['/developer-docs/latest/development/plugins-extension.md', 'Plugins extension'],
['/developer-docs/latest/development/plugins-development.md', 'Plugins development'],
['/developer-docs/latest/development/custom-fields.md', 'Custom fields'],
['/developer-docs/latest/development/typescript.md', 'TypeScript'],
['/developer-docs/latest/development/providers.md', 'Providers'],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Within the register function, a plugin can:
* [create a new settings section](#createsettingsection)
* define [injection zones](#injection-zones-api)
* [add reducers](#reducers-api)
* register the admin panel part of [custom fields](/developer-docs/latest/development/custom-fields.md#registering-a-custom-field-in-the-admin-panel)

#### registerPlugin()

Expand Down Expand Up @@ -180,6 +181,7 @@ The Admin Panel API allows a plugin to take advantage of several small APIs to p
| Declare an injection zone | [Injection Zones API](#injection-zones-api) | [`registerPlugin()`](#registerplugin) | [`register()`](#register) |
| Add a reducer | [Reducers API](#reducers-api) | [`addReducers()`](#reducers-api) | [`register()`](#register) |
| Create a hook | [Hooks API](#hooks-api) | [`createHook()`](#hooks-api) | [`register()`](#register) |
| 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()` |
| Add a single link to a settings section | [Settings API](#settings-api) | [`addSettingsLink()`](#addsettingslink) | [`bootstrap()`](#bootstrap) |
| Add multiple links to a settings section | [Settings API](#settings-api) | [`addSettingsLinks()`](#addsettingslinks) | [`bootstrap()`](#bootstrap) |
| Inject a Component in an injection zone | [Injection Zones API](#injection-zones-api) | [`injectComponent()`](#injection-zones-api) | [`bootstrap()`](#register) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To tap into the Server API, create a `strapi-server.js` file at the root of the

### register()

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.
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.

**Type**: `Function`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ Many types of attributes are available:

- scalar types (e.g. strings, dates, numbers, booleans, etc.),
- Strapi-specific types, such as:
- `media`, for files uploaded through the [Media library](/user-docs/latest/content-types-builder/configuring-fields-content-type.md#media)
- `media` for files uploaded through the [Media library](/user-docs/latest/content-types-builder/configuring-fields-content-type.md#media)
- `relation` to describe a [relation](#relations) between content-types
- `customField` to describe [custom fields](#custom-fields) and their specific keys
- `component` to define a [component](#components-2) (i.e. a data structure usable in multiple content-types)
- `dynamiczone` to define a [dynamic zone](#dynamic-zones) (i.e. a flexible space based on a list of components)
- and the `locale` and `localizations` types, only used by the [Internationalization (i18n) plugin](/developer-docs/latest/plugins/i18n.md)
Expand All @@ -118,7 +119,7 @@ The `type` parameter of an attribute should be one of the following values:
| Date types | <ul><li>`date`</li> <li>`time`</li> <li>`datetime`</li> <li>`timestamp`</li></ul> |
| Number types | <ul><li>`integer`</li><li>`biginteger`</li><li>`float`</li> <li>`decimal`</li></ul> |
| Other generic types |<ul><li>`boolean`</li><li>`array`</li><li>`json`</li></ul> |
| 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> |
| 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> |
| 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> |

#### Validations
Expand Down Expand Up @@ -494,6 +495,35 @@ The `tableName` key defines the name of the join table. It has to be specified o
:::::
#### Custom fields
[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`.
Custom fields' attributes also accept:

Custom fields' attributes also show the following specificities:
- a `customField` attribute whose value acts as a unique identifier to indicate which registered custom field should be used. Its value follows:
- either the `plugin::plugin-name.field-name` format if a plugin created the custom field
- or the `global::field-name` format for a custom field specific to the current Strapi application
- 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)).
```json
// path: ./src/api/[apiName]/[content-type-name]/content-types/schema.json
{
// …
"attributes": {
"attributeName": { // attributeName would be replaced by the actual attribute name
"type": "customField",
"customField": "plugin::color-picker.color",
"options": {
"format": "hex"
}
}
}
// …
}
```
#### Components
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:
Expand Down
Loading

0 comments on commit 0ea50df

Please sign in to comment.