docs updated
This commit is contained in:
+137
-298
@@ -5,374 +5,213 @@ include_toc: true
|
||||
|
||||
# Fields
|
||||
|
||||
Fields are similar to a table's columns in a relational databases.
|
||||
Fields define the columns of a schema. Each field has a `ui` type that controls both storage and the admin UI component rendered.
|
||||
|
||||
## Available fields for Collections and Files
|
||||
## Common Optional Properties
|
||||
|
||||
Most fields share these optional properties:
|
||||
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `required` | Whether the field must have a value to save as `published` |
|
||||
| `nullable` | Allow saving as `null` |
|
||||
| `help` | Help text shown below the input |
|
||||
| `default` | Default value when creating a new record |
|
||||
| `readonly` | Prevent editing from the UI |
|
||||
| `group` | Tab group this field belongs to |
|
||||
|
||||
|
||||
## Field Types
|
||||
|
||||
### text
|
||||
One-line text input
|
||||
|
||||
required
|
||||
One-line text input.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum character count |
|
||||
| `max` | Maximum character count |
|
||||
| `selectOptions` | Array of options. Strings or `[{value, label}]` objects |
|
||||
| `optionsFrom` | Schema name to load options from |
|
||||
| `optionsField` | Field from `optionsFrom` to use as the value |
|
||||
| `optionsSuggest` | Allow typing new values not in the options list |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **optionsFrom**: Schema to choose options from
|
||||
- **optionsField**: Field's value to insert
|
||||
- **optionsSuggest**: Allow to insert new values
|
||||
- **selectOptions**: Array of options to select from. Or array of objects `[{value,label}]`
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### textarea
|
||||
textarea input
|
||||
|
||||
required
|
||||
Multi-line text input.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum character count |
|
||||
| `max` | Maximum character count |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### slug
|
||||
Slug input. Generates automatically if left empty
|
||||
|
||||
required
|
||||
Slug input. Auto-generates from a source field if left empty.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **source**: The source field from which it generates
|
||||
**Required:** `name`, `label`, `source`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `source` | Field name to generate the slug from |
|
||||
| `min` | Minimum character count |
|
||||
| `max` | Maximum character count |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### rich
|
||||
WYSIWYG editor
|
||||
|
||||
required
|
||||
WYSIWYG rich text editor.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum character count |
|
||||
| `max` | Maximum character count |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### markdown
|
||||
|
||||
Markdown editor.
|
||||
|
||||
**Required:** `name`, `label`
|
||||
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum character count |
|
||||
| `max` | Maximum character count |
|
||||
|
||||
---
|
||||
|
||||
### number
|
||||
Any numeric value
|
||||
|
||||
required
|
||||
Numeric input.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `decimals` | Number of decimal places. Default: `0` |
|
||||
| `min` | Minimum value |
|
||||
| `max` | Maximum value |
|
||||
| `optionsFrom` | Schema name to load options from |
|
||||
| `optionsField` | Field from `optionsFrom` to use as the value |
|
||||
| `optionsSuggest` | Allow typing new values not in the options list |
|
||||
|
||||
- **decimals**: default is 0
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **optionsFrom**: Schema to choose options from
|
||||
- **optionsField**: Field's value to insert
|
||||
- **optionsSuggest**: Allow to insert new values
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### checkbox
|
||||
True or false
|
||||
|
||||
required
|
||||
Boolean true/false toggle.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### color
|
||||
Color picker
|
||||
|
||||
required
|
||||
Color picker.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `selectOptions` | Restrict to a predefined palette |
|
||||
| `optionsFrom` | Schema name to load options from |
|
||||
| `optionsField` | Field from `optionsFrom` to use as the value |
|
||||
| `optionsSuggest` | Allow typing new values not in the options list |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **optionsFrom**: Schema to choose options from
|
||||
- **optionsField**: Field's value to insert
|
||||
- **optionsSuggest**: Allow to insert new values
|
||||
- **selectOptions**: Array of options to select from. Or array of objects `[{value,label}]`
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### date
|
||||
Date select
|
||||
|
||||
required
|
||||
Date selector. Stores as a date string.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum date |
|
||||
| `max` | Maximum date |
|
||||
| `selectOptions` | Predefined date options |
|
||||
| `optionsFrom` | Schema name to load options from |
|
||||
| `optionsField` | Field from `optionsFrom` to use as the value |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **optionsFrom**: Schema to choose options from
|
||||
- **optionsField**: Field's value to insert
|
||||
- **optionsSuggest**: Allow to insert new values
|
||||
- **selectOptions**: Array of options to select from. Or array of objects `[{value,label}]`
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### datetime
|
||||
Date and time selector
|
||||
|
||||
required
|
||||
Date and time selector. Stores as an ISO 8601 string.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `min` | Minimum datetime |
|
||||
| `max` | Maximum datetime |
|
||||
| `selectOptions` | Predefined datetime options |
|
||||
| `optionsFrom` | Schema name to load options from |
|
||||
| `optionsField` | Field from `optionsFrom` to use as the value |
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **optionsFrom**: Schema to choose options from
|
||||
- **optionsField**: Field's value to insert
|
||||
- **optionsSuggest**: Allow to insert new values
|
||||
- **selectOptions**: Array of options to select from. Or array of objects `[{value,label}]`
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### json
|
||||
Json data
|
||||
|
||||
required
|
||||
Raw JSON data field.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
**Required:** `name`, `label`
|
||||
|
||||
optional
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
|
||||
### markdown
|
||||
Markdown editor
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
|
||||
optional
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum characters
|
||||
- **max**: Maximum characters
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
### file
|
||||
Upload or select files
|
||||
|
||||
required
|
||||
Upload or select files from a files schema.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **collections**: File collections to choose from
|
||||
**Required:** `name`, `label`, `collections`
|
||||
|
||||
optional
|
||||
|
||||
- **mime**: The mime types allowed to select
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum files
|
||||
- **max**: Maximum files
|
||||
- **help**: Help text
|
||||
- **group**: The group that this field belongs to
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `collections` | Array of file schema names to choose from |
|
||||
| `mime` | Allowed MIME types e.g. `["image/*"]` |
|
||||
| `min` | Minimum number of files |
|
||||
| `max` | Maximum number of files |
|
||||
|
||||
---
|
||||
|
||||
### reference
|
||||
Reference other records
|
||||
|
||||
required
|
||||
Reference records from another collection.
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **collections**: Collections to choose from
|
||||
**Required:** `name`, `label`, `collections`
|
||||
|
||||
optional
|
||||
| Property | Description |
|
||||
|---|---|
|
||||
| `collections` | Array of collection schema names to reference |
|
||||
| `min` | Minimum number of references |
|
||||
| `max` | Maximum number of references |
|
||||
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **min**: Minimum files
|
||||
- **max**: Maximum files
|
||||
- **help**: Help text
|
||||
- **group**: The group that this field belongs to
|
||||
---
|
||||
|
||||
## Example Field
|
||||
|
||||
### block
|
||||
The block editor
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **schema**: The block schema name
|
||||
|
||||
optional
|
||||
|
||||
- **required**: Is the field required to save the record
|
||||
- **nullable**: Can the field be saved as null
|
||||
- **help**: Help text
|
||||
- **default**: Default value when creating new record
|
||||
- **readonly**: Cannot edit this value from the UI
|
||||
- **group**: The group that this field belongs to
|
||||
|
||||
)
|
||||
## Available fields for the Block Editor
|
||||
|
||||
### heading
|
||||
Single-line text
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
|
||||
optional
|
||||
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
|
||||
### textarea
|
||||
Multiline text
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
|
||||
optional
|
||||
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
|
||||
### rich
|
||||
WYSIWYG editor
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
|
||||
optional
|
||||
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
|
||||
|
||||
### markdown
|
||||
Markdown editor
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
|
||||
optional
|
||||
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
|
||||
### file
|
||||
Choose files
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **collections**: File collections to choose from
|
||||
|
||||
optional
|
||||
- **mime**: The mime types allowed to select
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
|
||||
### reference
|
||||
Choose files
|
||||
|
||||
required
|
||||
|
||||
- **name**: The id of the field
|
||||
- **label**: The friendly name of the field
|
||||
- **collections**: Collections to choose from
|
||||
|
||||
optional
|
||||
- **min**: Minimum date
|
||||
- **max**: Maximum date
|
||||
- **default**: Default value when creating new record
|
||||
```json
|
||||
{
|
||||
"ui": "text",
|
||||
"name": "title",
|
||||
"label": "Title",
|
||||
"required": true,
|
||||
"min": 3,
|
||||
"max": 200,
|
||||
"help": "The main title of the post"
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user