function hook_field_ui_preconfigured_options_alter
Same name in other branches
- 9 core/modules/field/field.api.php \hook_field_ui_preconfigured_options_alter()
- 8.9.x core/modules/field/field.api.php \hook_field_ui_preconfigured_options_alter()
- 11.x core/modules/field/field.api.php \hook_field_ui_preconfigured_options_alter()
Perform alterations on preconfigured field options.
Parameters
array $options: Array of options as returned from \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions().
string $field_type: The field type plugin ID.
See also
\Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions()
Related topics
3 functions implement hook_field_ui_preconfigured_options_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- field_test_field_ui_preconfigured_options_alter in core/
modules/ field/ tests/ modules/ field_test/ field_test.module - Implements hook_field_ui_preconfigured_options_alter().
- media_field_ui_preconfigured_options_alter in core/
modules/ media/ media.module - Implements hook_field_ui_preconfigured_options_alter().
- media_library_field_ui_preconfigured_options_alter in core/
modules/ media_library/ media_library.module - Implements hook_field_ui_preconfigured_options_alter().
File
-
core/
modules/ field/ field.api.php, line 91
Code
function hook_field_ui_preconfigured_options_alter(array &$options, $field_type) {
// If the field is not an "entity_reference"-based field, bail out.
/** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$class = $field_type_manager->getPluginClass($field_type);
if (!is_a($class, 'Drupal\\Core\\Field\\Plugin\\Field\\FieldType\\EntityReferenceItem', TRUE)) {
return;
}
// Set the default formatter for media in entity reference fields to be the
// "Rendered entity" formatter.
if (!empty($options['media'])) {
$options['media']['entity_view_display']['type'] = 'entity_reference_entity_view';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.