public function FieldStateInterface::applyState in Field States UI 8
Same name and namespace in other branches
- 8.2 src/FieldStateInterface.php \Drupal\field_states_ui\FieldStateInterface::applyState()
Applies a field state to the field widget's form element.
Parameters
array $states: An array to hold states.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $context: An associative array containing the following key-value pairs:
- form: The form structure to which widgets are being attached. This may be a full form structure, or a sub-element of a larger form.
- widget: The widget plugin instance.
- items: The field values, as a \Drupal\Core\Field\FieldItemListInterface object.
- delta: The order of this item in the array of sub-elements (0, 1, n).
- default: A boolean indicating whether the form is being shown as a dummy form to set default values.
array $element: The field widget form element as constructed by hook_field_widget_form().
array $parents: The parents array from the element.
Return value
bool TRUE on success. FALSE if unable to calculate the field state.
See also
\Drupal\Core\Field\WidgetBase::formSingleElement()
hook_field_widget_form_alter()
1 method overrides FieldStateInterface::applyState()
- FieldStateBase::applyState in src/
FieldStateBase.php - Applies a field state to the field widget's form element.
File
- src/
FieldStateInterface.php, line 47
Class
- FieldStateInterface
- Defines the interface for field states.
Namespace
Drupal\field_states_uiCode
public function applyState(array &$states, FormStateInterface $form_state, array $context, array $element, array $parents = NULL);