function WidgetBase::getWidgetStateParents

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

Returns the location of processing information within $form_state.

Parameters

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

string $field_name: The field name.

Return value

array The location of processing information within $form_state.

2 calls to WidgetBase::getWidgetStateParents()
WidgetBase::getWidgetState in core/lib/Drupal/Core/Field/WidgetBase.php
WidgetBase::setWidgetState in core/lib/Drupal/Core/Field/WidgetBase.php

File

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

Class

WidgetBase
Base class for 'Field widget' plugin implementations.

Namespace

Drupal\Core\Field

Code

protected static function getWidgetStateParents(array $parents, $field_name) {
    // Field processing data is placed at
    // $form_state->get(['field_storage', '#parents', ...$parents..., '#fields', $field_name]),
    // to avoid clashes between field names and $parents parts.
    return array_merge([
        'field_storage',
        '#parents',
    ], $parents, [
        '#fields',
        $field_name,
    ]);
}

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