FormField
class FormField
Form Field definition A translation of the form field configuration
Adapted from october\backend\classes\FormField
Constants
NO_SAVE_DATA |
|
Properties
string | $fieldName | ||
string | $arrayName | ||
string | $idPrefix | ||
string | $label | ||
string | $value | ||
string | $valueFrom | ||
string | $defaults | ||
string | $defaultFrom | ||
string | $tab | ||
string | $type | ||
string | $options | ||
string | $span | ||
string | $size | ||
string | $context | ||
bool | $required | ||
bool | $readOnly | ||
bool | $disabled | ||
$hidden | |||
bool | $stretch | ||
string | $comment | ||
string | $commentPosition | ||
string | $commentHtml | ||
string | $placeholder | ||
array | $attributes | ||
string | $cssClass | ||
string | $path | ||
array | $config | ||
array | $dependsOn | ||
array | $trigger | ||
array | $preset |
Methods
Constructor.
If this field belongs to a tab.
Sets a side of the field on a form.
Sets a side of the field on a form.
Sets field options, for dropdowns, radio lists and checkbox lists.
Specifies a field control rendering mode. Supported modes are:
- text - creates a text field. Default for varchar column types.
Process options and apply them to this object.
Adds a text comment above or below the field.
Sets the attributes for this field in a given position.
Checks if the field has the supplied [unfiltered] attribute.
Returns the attributes for this field at a given position.
Adds any circumstantial attributes to the field based on other settings, such as the 'disabled' option.
Adds attributes used specifically by the Trigger API
Adds attributes used specifically by the Input Preset API
Returns a value suitable for the field name property.
Returns a value suitable for the field id property.
Returns a raw config item value.
Returns this fields value from a supplied data set, which can be an array or a model or another generic collection.
Returns the default value for this field, the supplied data is used to source data when defaultFrom is specified.
Returns the final model and attribute name of a nested attribute.
Internal method to extract the value of a field name from a data set.
Details
at line 178
__construct(string $fieldName, string $label)
Constructor.
at line 191
$this
tab($value)
If this field belongs to a tab.
at line 205
$this
span(string $value = 'full')
Sets a side of the field on a form.
at line 219
$this
size(string $value = 'large')
Sets a side of the field on a form.
at line 233
FormField|array
options(array $value = null)
Sets field options, for dropdowns, radio lists and checkbox lists.
at line 269
$this
displayAs(string $type, array $config = [])
Specifies a field control rendering mode. Supported modes are:
- text - creates a text field. Default for varchar column types.
- textarea - creates a textarea control. Default for text column types.
- select - creates a drop-down list. Default for reference-based columns.
- radio - creates a set of radio buttons.
- checkbox - creates a single checkbox.
- checkboxlist - creates a checkbox list.
- radiolist - creates a radio list.
at line 284
protected array
evalConfig(array $config)
Process options and apply them to this object.
at line 368
$this
comment(string $text, string $position = 'below', bool $isHtml = null)
Adds a text comment above or below the field.
at line 390
FormField
attributes(array $items, string $position = 'field')
Sets the attributes for this field in a given position.
- field: Attributes are added to the form field element (input, select, textarea, etc)
- container: Attributes are added to the form field container (div.form-group)
at line 418
bool
hasAttribute(string $name, string $position = 'field')
Checks if the field has the supplied [unfiltered] attribute.
at line 436
string
getAttributes(string $position = 'field', bool $htmlBuild = TRUE)
Returns the attributes for this field at a given position.
at line 453
protected array
filterAttributes(array $attributes, string $position = 'field')
Adds any circumstantial attributes to the field based on other settings, such as the 'disabled' option.
at line 483
protected array
filterTriggerAttributes(array $attributes, string $position = 'field')
Adds attributes used specifically by the Trigger API
at line 530
protected array
filterPresetAttributes(array $attributes, string $position = 'field')
Adds attributes used specifically by the Input Preset API
at line 572
string
getName(string $arrayName = null)
Returns a value suitable for the field name property.
at line 593
string
getId(string $suffix = null)
Returns a value suitable for the field id property.
at line 621
mixed
getConfig(string $value, string $default = null)
Returns a raw config item value.
at line 635
mixed
getValueFromData(mixed $data, mixed $default = null)
Returns this fields value from a supplied data set, which can be an array or a model or another generic collection.
at line 650
mixed
getDefaultFromData(mixed $data)
Returns the default value for this field, the supplied data is used to source data when defaultFrom is specified.
at line 672
array
resolveModelAttribute($model, string $attribute = null)
Returns the final model and attribute name of a nested attribute.
Eg: list($model, $attribute) = $this->resolveAttribute('person[phone]');
at line 697
protected mixed
getFieldNameFromData(string $fieldName, mixed $data, mixed $default = null)
Internal method to extract the value of a field name from a data set.