You are here

public function DynamicEntityReferenceOptionsTrait::massageFormValues in Dynamic Entity Reference 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/DynamicEntityReferenceOptionsTrait.php \Drupal\dynamic_entity_reference\Plugin\Field\FieldWidget\DynamicEntityReferenceOptionsTrait::massageFormValues()

To save both target_type and target_id the option value is split into target_type and target_id.

See also

\Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem::getSettableOptions()

File

src/Plugin/Field/FieldWidget/DynamicEntityReferenceOptionsTrait.php, line 55

Class

DynamicEntityReferenceOptionsTrait
The common functionality between DynamicEntityReferenceOptionsWidgets.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldWidget

Code

public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
  foreach ($values as $index => $value) {
    list($values[$index]['target_type'], $values[$index]['target_id']) = explode('-', $value['target_id']);
  }
  return $values;
}