Files
payloadcms/docs/Fields/overview.mdx
2020-12-30 12:08:39 -05:00

52 lines
2.1 KiB
Plaintext

---
title: Fields Overview
label: Overview
order: 10
---
<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>
Fields are defined as an array on Collections and Globals via the `fields` key. They define the shape of the data that will be stored on Collections and Globals as well as automatically construct the corresponding Admin UI.
The required `type` property on a field determines what values it can accept, how it is presented in the API, and how the field will be rendered in the admin interface.
**Simple collection with two fields:**
```js
const Pages = {
slug: 'pages',
fields: [
{
name: 'my-field',
type: 'text', // highlight-line
label: 'My Field',
},
{
name: 'other-field',
type: 'checkbox', // highlight-line
label: 'Other Field'
},
],
}
```
### Field types
- [Array](/docs/fields/array) - for repeating content, supports nested fields
- [Blocks](/docs/fields/blocks) - block-based fields, allowing powerful layout creation
- [Checkbox](/docs/fields/checkbox) - boolean true / false checkbox
- [Code](/docs/fields/code) - xode editor that saves a string to the database
- [Date](/docs/fields/date) - date / time field that saves a timestamp
- [Email](/docs/fields/email) - validates the entry is a properly formatted email
- [Group](/docs/fields/group) -
- [Number](/docs/fields/number) - field that enforces that its value be a number
- [Radio](/docs/fields/radio) - Radio button group, allowing only one value to be selected
- [Relationship](/docs/fields/relationship) - Assign relationships to other collections
- [Rich Text](/docs/fields/rich-text) - Fully extensible Rich Text editor
- [Row](/docs/fields/row) - Used for admin field layout, no effect on data shape
- [Select](/docs/fields/select) - Dropdown / picklist style based on `react-select`
- [Text](/docs/fields/text) - simple text input
- [Textarea](/docs/fields/textarea) - allows a bit larger of a text editor
- [Upload](/docs/fields/upload) - Allows local file and image upload