Choice enum
Purpose: list of possible key-value options
Field type in SQL table: int, float, char, varchar
Additional parameters:
values_list
Purpose: list of possible values as an array (regular or associated)
Possible values: ['green', 'blue', 'red'] or ['green' => 'green', 'blue' => 'blue', 'red' => 'red'] (the second option is preferable)
Default: []
empty_value
Purpose: the ability to select an empty value for the field
Possible values: true or text that will be shown as a title for the empty value
Default: true
foreign_key
Purpose: foreign key, the case when the values for this field are taken from another model, more details in the section Foreign keys
Possible values: model name: 'News', ‘Products'
Default: null
is_parent
Purpose: used together with foreign_key, shows that this foreign key, records of another model are parents for records current model (such as product catalogs). The second model must have a parent type field. For more information, see the Trees section.
Possible values: true, false
Default: false
name_field
Purpose: used together with foreign_key, when displaying a list of possible values in the related model, a field named name is searched for, if this field is missing, then you must specify the field that will be used as a named field
Possible values: field name, for example 'first_name', 'label', 'date'
Default: 'name'
name_field_extra
Purpose: used together with foreign_key and name_field, allows you to add the value of another field to the name_field field from the related model for easier perception in the list
Possible values: field name, for example 'last_name', 'age', ‘job’
Default: empty string
display_radio
Purpose: sets the display of field values (only in views) as radio buttons (initially the select tag is displayed)
Possible values: integer indicating the number of columns with radio buttons
Default: false
long_list
Purpose: used if the list of values is long, then the values are obtained using the search string
Possible values: true, false
Default: false
show_parent
Purpose: used together with foreign_key and is_parent, additionally shows the name of the parent for the field values
Possible values: true, false
Default: false
multiple_choice
Purpose: multiple choice, the field is displayed in the form as a table with checkboxes, the number of table columns is set using the value of this parameter (used only for forms built without a model)
Possible values: positive integer values that indicate the number of columns in the table with checkboxes
Default: false
order_asc, order_desc
Purpose: used together with foreign_key, allows you to sort the list of foreign key values by one of the model fields, by default, when retrieving foreign key data, sorting occurs by name (or the named field name_field).
Possible values: string, names of model fields
Default: false
Examples:
['Status', 'enum', 'status', ['values_list' => [
'placed' => 'Postned',
'paied' => 'Paid',
'delivered' => 'Delivered']]]
['City', 'enum', 'city', ['foreign_key' => 'Cities',
'empty_value' => 'All cities',
'long_list' => true]]
['Brand', 'enum', 'brand', ['empty_value' => true,
'foreign_key' =>'Brands',
'order_desc' => 'date']]
['Client', 'enum', 'client', ['foreign_key' => 'Clients',
'name_field' => 'first_name',
'name_field_extra' => 'last_name']]
['Directory section', 'enum', 'parent', ['foreign_key' => 'Catalogs',
'is_parent' => true,
'show_parent' => true]]
Previous section
Array of images