public function EntityReferenceRevisionsFieldItemList::defaultValuesFormSubmit in Entity Reference Revisions 8
Processes the submitted default value.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure instance-level default value.
Parameters
array $element: The default value form element.
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
Return value
array The field default value.
Overrides EntityReferenceFieldItemList::defaultValuesFormSubmit
File
- src/
EntityReferenceRevisionsFieldItemList.php, line 102
Class
- EntityReferenceRevisionsFieldItemList
- Defines a item list class for entity reference fields.
Namespace
Drupal\entity_reference_revisionsCode
public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) {
$default_value = parent::defaultValuesFormSubmit($element, $form, $form_state);
// Convert numeric IDs to UUIDs to ensure config deployability.
$ids = array();
foreach ($default_value as $delta => $properties) {
$ids[] = $properties['target_revision_id'];
}
$entities = array();
foreach ($ids as $id) {
$entities[$id] = \Drupal::entityTypeManager()
->getStorage($this
->getSetting('target_type'))
->loadRevision($id);
}
foreach ($default_value as $delta => $properties) {
$default_value[$delta] = array(
'target_uuid' => $entities[$properties['target_revision_id']]
->uuid(),
'target_revision_id' => $properties['target_revision_id'],
);
}
return $default_value;
}