You are here

public function ViewsReferenceTrait::massageValues in Views Reference Field 8

Helper function to flatten options array.

2 calls to ViewsReferenceTrait::massageValues()
ViewsReferenceSelectWidget::massageFormValues in src/Plugin/Field/FieldWidget/ViewsReferenceSelectWidget.php
Massages the form values into the format expected for field values.
ViewsReferenceWidget::massageFormValues in src/Plugin/Field/FieldWidget/ViewsReferenceWidget.php
Massages the form values into the format expected for field values.

File

src/Plugin/Field/FieldWidget/ViewsReferenceTrait.php, line 236

Class

ViewsReferenceTrait
Trait for shared code in Viewsreference Field Widgets.

Namespace

Drupal\viewsreference\Plugin\Field\FieldWidget

Code

public function massageValues(array $values, array $form, FormStateInterface $form_state) {
  foreach ($values as $key => $value) {
    if (is_array($value['options'])) {
      foreach ($value['options'] as $ind => $option) {
        $values[$key][$ind] = $option;
      }
      unset($value['options']);
    }
  }
  return $values;
}