Skip to content

Fields

Intro

Fields are the input elements for strategy in elements

Fields relationships

Fields have a number of relationships:

  • parents()
  • children()

Field children

Field children are linked to to the field groups. This attribute is associated automatically when a field is retrieved via the getChildrenAttribute() method.

This relationship is stores in the field_children table with order pivot. The reason it is handled in a separate table is to element tab fields is because the order will be independent to the element tab fields.

Field parents

Field parents are the parents of the children fields. Although a BelongsToMany relationship, there will only ever be one parent to a field.

Field nesting limit

Field nesting is limited to 3 levels, ie: You can have the following:

  1. Field Group: (Level 1 - All fields allowed as children)
  2. Field Group repeater: (Level 2 - All fields allowed as children)
  3. Single-line text field: (Level 3 - Only non-group fields allowed)

The field nesting limit is handled in the ElementTabFieldController class using logic that checks if a field's parent has a parent. Eg:

 'fieldTypes' => $parent_field->parent_id ? FieldTypes::selectGroupValues() : FieldTypes::selectValues(),

Additional details

Some fields have additional optional settings that admins can set.

Character limit

An optional constraint to limit the number of characters which can be input. Only available to single-line-text fields. If utilised, stored as single_line_text_field_character_limit property of meta object/DB column.

Field suffix

An optional custom suffix or unit for the field input. Only available to single-line-text and number fields.If utilised, stored as suffix property of meta object/DB column.

Information modals

All fields have an information modal setting which can be turned on by admins. This setting is stored as a boolean value in the information_active column of the fields table. If an admin sets this value to true then a WYSIWYG editor field will appear in the field form where the admin can add the relevant content they want displayed to users when the modal fires. The content is stored in the information_content column of the fields table.

On the front-end, the information modal is triggered by clicking the i icon in the actions area to the right of field title. The modal will display the content added by the admin.