docs(fields): add common options

This commit is contained in:
Elliot DeNolf
2020-11-11 15:39:21 -05:00
parent 27e5dc4d55
commit 7caa025278
2 changed files with 51 additions and 10 deletions

View File

@@ -4,11 +4,59 @@ label: Overview
order: 10
---
Collections are composed of any number of fields. Payload offers a wide-array of field-types - both simple and complex.
<Banner type="info">
Fields are the building blocks of Payload. Collections and Globals both use Fields to define the shape of the data that they store. Payload offers a wide-array of field-types - both simple and complex.
</Banner>
## Common Options
Most fields have the ability to use the following options
#### `defaultValue`
Initial value for the field
#### `required`
`true/false` value if the field is required to be populated
#### `localized`
`true/false` value to enable localization on the field
#### `admin`
The `admin` is an optional object with properties that specify how the field should be represented in the admin interface.
Properties:
- `position` - If specified as `sidebar`, the field will show in the admin interface's sidebar
- `width` - A percentage value ie. `50%` that will control the max-width of the field
- `readOnly` - `true/false` to set the field to read-only after it is saved
### Common Options Example
```js
// Collection config
{
fields: [
{
name: 'my-field',
type: 'text',
label: 'Text',
admin: {
position: 'sidebar',
width: '50%',
readOnly: true,
}
}
]
}
```
## Field types
When configuring a field in a collection, there are multiple values to set for the `type`. This type determines how the input will be rendered in the admin interface, what values it can accept, and how it is presented in the API.
The `type` property on a field determines how the input will be rendered in the admin interface, what values it can accept, and how it is presented in the API.
```js
// Collection config
@@ -23,13 +71,6 @@ When configuring a field in a collection, there are multiple values to set for t
}
```
### Common Options
- `defaultValue`
- `required` - boolean
- `localized` - boolean
- `admin` - _TODO: Document all options_
### Simple Types
#### `text`

View File

@@ -36,4 +36,4 @@ You can define as many Collections as you need. On each Collection, you can spec
Fields are the building blocks of Payload. Collections and Globals both use Fields to define the shape of the data that they store.
</Banner>
Payload comes with many different types of Fields that give you a ton of flexibility while designing your API. Each Field type has its own potential properties that allow you to customize how they work.
Payload comes with [many different types](../fields/overview) of Fields that give you a ton of flexibility while designing your API. Each Field type has its own potential properties that allow you to customize how they work.