Skip to content

Field types

Thomas van der Veen edited this page May 28, 2020 · 13 revisions

The type property will allow you to control how a field should behave.

Default

By default all fields will be handled by the input field. This means this package will use this type whenever a value for type in the field configuration is used that has not been configured in the cms.fields.classes array.


Input

Usage: 'type' => 'text'
Class: InputField

This field is focused on rendering an <input> element. It will use the value of type that has been configured in your field configuration as the type attribute of the <input> element.

'type' => 'date' will lead to <input type="date">. All possible input types could be found here.

Remeber that this field is used as fallback when no other field type can be found in the configured cms.fields.classes.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
input_attributes array An array that is used to pass on additional attributes to the rendered <input> element. All possible attributes could for example be found here.

Checkbox

Usage: 'type' => 'checkbox'
Class: CheckableField


Entry select

Usage: 'type' => 'entry_select'
Class: EntrySelectField

This field will render a <select> element with <option> that represent entries of the configured entry_type.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
entry_type string A type of entry that is used to fetch from the database.
input_attributes array An array that is used to pass on additional attributes to the rendered <select> element. All possible attributes could for example be found here.
list_item_label_key string A string of a property name from the model that is used to display as option label. This value can be dot notated to retrieve deep properties.
query_constraint callable A callback that is used to alter the query that fetches records from the database. Eg: 'query_constraint' => function ($q) { $q->limit(15); }

File

Usage: 'type' => 'file'
Class: FileField

A field that will render an input where the user can select a file to upload.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
file_path string A path to a directory in your default storage disk where the files should be stored.

Model select

Usage: 'type' => 'model_select'
Class: ModelSelectField

This field will render a <select> element with <option> that represent database records of the configured model_class.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
list_item_label_key string A string of a property name from the model that is used to display as option label. This value can be dot notated to retrieve deep properties.
input_attributes array An array that is used to pass on additional attributes to the rendered <select> element. All possible attributes could for example be found here.
model_class string A class name of the model that is used to fetch records from the database
query_constraint callable A callback that is used to alter the query that fetches records from the database. Eg: 'query_constraint' => function ($q) { $q->limit(15); }

Multi select

Usage: 'type' => 'multi_select'
Class: MultiSelectField

A field that renders a dropdown where the user can select multiple options.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
list array An array of options that will be rendered in the dropdown where the key is the value that is being stored and the value is the label being displayed.

Radio

Usage: 'type' => 'radio'
Class: CheckableField


Select

Usage: 'type' => 'select'
Class: SelectField

This field will render a <select> element with <option> elements that are configured in the list property.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
input_attributes array An array that is used to pass on additional attributes to the rendered <select> element. All possible attributes could for example be found here.
list array An array of options that will be rendered as <option> elements where the key is the value that is being stored and the value is the label being displayed.

Textarea

Usage: 'type' => 'textarea'
Class: TextAreaField

A field that will render a <textarea> element.

Additional configuration

This field allows additional configuration in the config property.

Property Type Description
input_attributes array An array that is used to pass on additional attributes to the rendered <textarea> element. All possible attributes could for example be found here.

Clone this wiki locally