Field configuration - larawhale/cms GitHub Wiki

Fields can be seen as the properties of an entry. Fields keep track of the value, how they are validated, how the input field should be rendered in the user interface and much more.

Example

Field configurations are added to an entry configuration.

A typical field configuration for an entry would look something like this:

[
    'key' => 'title',
    'type' => 'text',
    'config' => [
        'label' => 'The title of the post',
        'rules' => 'required|string|max:191',
    ],
],

Properties

The following properties can be used to configure any field. More properties can be available in the config property depending on the type.

Property Type Description
key string required The value if this property is used as an identifier and should be unique within the same type of entry. This means you can have the same value for key in different type of entries. The value of this property will also be used as the accessor on the entry in your blade view. In this case that could be $entry->title, but more about this in the entry rendering section.
type string required The type property is an indicator for the package which type of field it is handling. According to the value it might render a different input field or store the value in a different way. By default this value will be used as the type value attribute of an input element. However it is also possible to create your own custom types, more about this in the field types section.
config array A configuration array that can contain multiple other properties that should help the application to handle the field.
config.label string This property will be used to display to the user, it is the label of the field. The package will try to translate this value, so a value like inputs.title.label might be translated.
config.rules array The value of the rules will be used to validate the input the user has given during creating or updating an entry. The rules are written exactly the same way as you are used to in a Laravel application. This means you could use custom rules, closures or other validation features Laravel supplies.