function WidgetBase::setWidgetState

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/WidgetBase.php \Drupal\Core\Field\WidgetBase::setWidgetState()
  2. 8.9.x core/lib/Drupal/Core/Field/WidgetBase.php \Drupal\Core\Field\WidgetBase::setWidgetState()
  3. 11.x core/lib/Drupal/Core/Field/WidgetBase.php \Drupal\Core\Field\WidgetBase::setWidgetState()

Stores processing information about the widget in $form_state.

This method is static so that it can be used in static Form API #callbacks.

Parameters

array $parents: The array of #parents where the widget lives in the form.

string $field_name: The field name.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

array $field_state: The array of data to store. See getWidgetState() for the structure and content of the array.

Overrides WidgetBaseInterface::setWidgetState

5 calls to WidgetBase::setWidgetState()
WidgetBase::addMoreSubmit in core/lib/Drupal/Core/Field/WidgetBase.php
Submission handler for the "Add another item" button.
WidgetBase::afterBuild in core/lib/Drupal/Core/Field/WidgetBase.php
After-build handler for field elements in a form.
WidgetBase::deleteSubmit in core/lib/Drupal/Core/Field/WidgetBase.php
Ajax submit callback for the "Remove" button.
WidgetBase::extractFormValues in core/lib/Drupal/Core/Field/WidgetBase.php
Extracts field values from submitted form values.
WidgetBase::form in core/lib/Drupal/Core/Field/WidgetBase.php
Creates a form element for a field.

File

core/lib/Drupal/Core/Field/WidgetBase.php, line 607

Class

WidgetBase
Base class for 'Field widget' plugin implementations.

Namespace

Drupal\Core\Field

Code

public static function setWidgetState(array $parents, $field_name, FormStateInterface $form_state, array $field_state) {
  NestedArray::setValue($form_state->getStorage(), static::getWidgetStateParents($parents, $field_name), $field_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.