Collection Schema
A collection schema is a JSON array of objects, where each object defines a property of that collection. For example, the schema of a simple blog post with a title and content might look like this:
[
{
"name": "title",
"label": "title",
"casts": "string",
"controltype": "text",
"required": true,
"value": ""
},
{
"name": "content",
"label": "Content",
"casts": "string",
"controltype": "htmleditor",
"validation": "min:10",
"value": ""
}
]
Defining Collection Properties
The following attributes can be used to define a collection property:
| Property | Description |
|---|---|
name |
Required. The field name |
label |
How the field is labelled in the admin. Default is a nicely formatted version of the name |
casts |
How the value is cast: any of the Textstem types, such as integer, float, date, datetime, boolean and string. Default is string |
controltype |
The control type used to enter or select the value. Default is a text input |
validation |
Laravel validation rules for this input |
required |
Whether a value is required. Default is false |
value |
The default value |
Some controls types have additional properties. For example, the asset_selector will accept a "type" attribute, and the radio_stack needs an "options" attribute which is an array of options (values).
Control Types
The following control types are available:
| Control Type | Additional Param | Description |
|---|---|---|
| asset_collection | type | widget for selecting and managing a list of one or more assets |
| asset_selector | type | widget for selecting an asset. If the type parameter is specified, then only assets of that type can be picked |
| category_select | -- | widget for selecting a category |
| datetime | -- | date and time picker |
| default | -- | default (text) |
| html | -- | html code |
| htmleditor | -- | wysiwyg html editor |
| image | -- | image picker |
| image_collection | -- | select one or more images |
| instructions | -- | text to be displayed as instructional text |
| markdown | -- | markdown editor |
| number | -- | number input |
| page_select | -- | select a page |
| page_selector | -- | select one or more pages |
| post_collection | -- | select one or more posts |
| post_selector | -- | select a post |
| radiostack | options (arr) | stack of radio buttons |
| raw_html | -- | textarea |
| rect-list | -- | -- |
| richtext | -- | alias of richtexteditor |
| richtexteditor | -- | simplified html editor for writing prose |
| select-template | -- | select a template |
| select | options | select / dropdown |
| text | -- | simple text input |
| textarea | -- | simple textarea |
| thumbnail | -- | thumbnail picker |
| video | -- | -- |
| yesno | -- | -- |