function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfigInterface
$field_storage, \Drupal\field\FieldStorageConfigInterface
$prior_field_storage) { if ($field_storage->
getTypeProvider() == 'options' &&
$field_storage->
hasData()) { // Forbid any update that removes allowed values with actual data.
$allowed_values =
$field_storage->
getSetting('allowed_values'
);
$prior_allowed_values =
$prior_field_storage->
getSetting('allowed_values'
);
$lost_keys =
array_keys(array_diff_key($prior_allowed_values,
$allowed_values));
if (_options_values_in_use($field_storage->
getTargetEntityTypeId(),
$field_storage->
getName(),
$lost_keys)) { throw new \Drupal\Core\Entity\Exception\
FieldStorageDefinitionUpdateForbiddenException("A list field '{
$field_storage->
getName()}' with existing data cannot have its keys changed."
);
} }}/**
* @} End of "defgroup field_types".
*/
/**
* @defgroup field_widget Field Widget API
* @{
* Define Field API widget types.
*
* Field API widgets specify how fields are displayed in edit forms. Fields of a
* given @link field_types field type @endlink may be edited using more than one
* widget. In this case, the Field UI module allows the site builder to choose
* which widget to use.
*
* Widgets are Plugins managed by the
* \Drupal\Core\Field\WidgetPluginManager class. A widget is a plugin annotated
* with class \Drupal\Core\Field\Annotation\FieldWidget that implements
* \Drupal\Core\Field\WidgetInterface (in most cases, by
* subclassing \Drupal\Core\Field\WidgetBase). Widget plugins need to be in the
* namespace \Drupal\{your_module}\Plugin\Field\FieldWidget.
*
* Widgets are @link form_api Form API @endlink elements with additional
* processing capabilities. The methods of the WidgetInterface object are
* typically called by respective methods in the
* \Drupal\Core\Entity\Entity\EntityFormDisplay class.
*
* @see field
* @see field_types
* @see field_formatter
* @see plugin_api
*/