// Ensure we return consecutive deltas, in case we removed unknown UUIDs.
$default_value =
array_values($default_value);
} return $default_value;
} /**
* {@inheritdoc}
*/
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 =
[];
foreach ($default_value as $delta =>
$properties) { if (isset($properties['entity'
]) &&
$properties['entity'
]->
isNew()) { // This may be a newly created term.
$properties['entity'
]->
save();
$default_value[$delta]['target_id'
] =
$properties['entity'
]->
id();
unset($default_value[$delta]['entity'
]);
} $ids[] =
$default_value[$delta]['target_id'
];
}