function TestItemWithPreconfiguredOptions::getPreconfiguredOptions
Same name and namespace in other branches
- 9 core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php \Drupal\field_test\Plugin\Field\FieldType\TestItemWithPreconfiguredOptions::getPreconfiguredOptions()
- 8.9.x core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php \Drupal\field_test\Plugin\Field\FieldType\TestItemWithPreconfiguredOptions::getPreconfiguredOptions()
- 11.x core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php \Drupal\field_test\Plugin\Field\FieldType\TestItemWithPreconfiguredOptions::getPreconfiguredOptions()
Returns preconfigured field options for a field type.
Note that if you want to give modules an opportunity to alter the result of this method, you should call \Drupal\Core\Field\FieldTypePluginManagerInterface::getPreconfiguredOptions() instead.
Return value
mixed[][] A multi-dimensional array with string keys and the following structure:
- label: The label to show in the field type selection list.
- category: (optional) The category in which to put the field label. Defaults to the category of the field type.
- field_storage_config: An array with the following supported keys:
- cardinality: The field cardinality.
- settings: Field-type specific storage settings.
- field_config: An array with the following supported keys:
- required: Indicates whether the field is required.
- settings: Field-type specific settings.
- entity_form_display: An array with the following supported keys:
- type: The widget to be used in the 'default' form mode.
- entity_view_display: An array with the following supported keys:
- type: The formatter to be used in the 'default' view mode.
Overrides PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions
File
-
core/
modules/ field/ tests/ modules/ field_test/ src/ Plugin/ Field/ FieldType/ TestItemWithPreconfiguredOptions.php, line 25
Class
- TestItemWithPreconfiguredOptions
- Defines the 'test_field_with_preconfigured_options' entity field item.
Namespace
Drupal\field_test\Plugin\Field\FieldTypeCode
public static function getPreconfiguredOptions() {
return [
'custom_options' => [
'label' => new TranslatableMarkup('All custom options'),
'field_storage_config' => [
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => [
'test_field_storage_setting' => 'preconfigured_storage_setting',
],
],
'field_config' => [
'required' => TRUE,
'settings' => [
'test_field_setting' => 'preconfigured_field_setting',
],
],
'entity_form_display' => [
'type' => 'test_field_widget_multiple',
],
'entity_view_display' => [
'type' => 'field_test_multiple',
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.