You are here

protected static function Select2Widget::prepareFieldValues in Select 2 8

Set's the values to the correct column key.

Parameters

array $values: The input values.

array $element: The render element.

Return value

array Values with the correct keys.

2 calls to Select2Widget::prepareFieldValues()
Select2EntityReferenceWidget::prepareFieldValues in src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php
Set's the values to the correct column key.
Select2Widget::validateElement in src/Plugin/Field/FieldWidget/Select2Widget.php
Form validation handler for widget elements.
1 method overrides Select2Widget::prepareFieldValues()
Select2EntityReferenceWidget::prepareFieldValues in src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php
Set's the values to the correct column key.

File

src/Plugin/Field/FieldWidget/Select2Widget.php, line 119

Class

Select2Widget
Plugin implementation of the 'select2' widget.

Namespace

Drupal\select2\Plugin\Field\FieldWidget

Code

protected static function prepareFieldValues(array $values, array $element) {

  // Transpose selections from field => delta to delta => field.
  $items = [];
  foreach ($values as $value) {
    $items[] = [
      $element['#key_column'] => $value,
    ];
  }
  return $items;
}