You are here

protected function ListWidget::extractNewValues in Select (or other) 4.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/ListWidget.php \Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::extractNewValues()

Extract unknown values found in the values array.

Parameters

array $values: The values.

Return value

array Any unknown values found in the values array.

1 call to ListWidget::extractNewValues()
ListWidget::massageFormValues in src/Plugin/Field/FieldWidget/ListWidget.php
Massages the form values into the format expected for field values.

File

src/Plugin/Field/FieldWidget/ListWidget.php, line 117

Class

ListWidget
Plugin implementation of the 'select_or_other_list' widget.

Namespace

Drupal\select_or_other\Plugin\Field\FieldWidget

Code

protected function extractNewValues(array $values) {
  $allowed_values = $this->fieldDefinition
    ->getSetting('allowed_values');
  $new_values = [];
  foreach ($values as $value) {
    if (!empty($value) && !isset($allowed_values[$value])) {
      $new_values[] = $value;
    }
  }
  return $new_values;
}