function FieldStorageAddForm::processFieldDefinitions
Same name in other branches
- 10 core/modules/field_ui/src/Form/FieldStorageAddForm.php \Drupal\field_ui\Form\FieldStorageAddForm::processFieldDefinitions()
Save field type definitions and categories in the form state.
Get all field type definitions and store each one twice:
- field_type_options: each field type is indexed by its category plugin ID or its label.
- unique_definitions: each field type is indexed by its category and name.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to FieldStorageAddForm::processFieldDefinitions()
- FieldStorageAddForm::buildForm in core/
modules/ field_ui/ src/ Form/ FieldStorageAddForm.php - Form constructor.
File
-
core/
modules/ field_ui/ src/ Form/ FieldStorageAddForm.php, line 128
Class
- FieldStorageAddForm
- Provides a form for the "field storage" add page.
Namespace
Drupal\field_ui\FormCode
protected function processFieldDefinitions(FormStateInterface $form_state) : void {
$field_type_options = $unique_definitions = [];
$grouped_definitions = $this->fieldTypePluginManager
->getGroupedDefinitions($this->fieldTypePluginManager
->getEntityTypeUiDefinitions($this->entityTypeId), 'label', 'id');
foreach ($grouped_definitions as $category => $field_types) {
foreach ($field_types as $name => $field_type) {
$definition = [
'unique_identifier' => $name,
] + $field_type;
$category_info = $this->fieldTypeCategoryManager
->createInstance($field_type['category'], $definition);
$definition['display_as_group'] = !$category_info instanceof FallbackFieldTypeCategory;
$id = $this->fieldTypeCategoryManager
->hasDefinition($category) ? $category_info->getPluginId() : (string) $field_type['label'];
$field_type_options[$id] = $definition;
$unique_definitions[$category][$name] = $definition;
}
}
$form_state->set('field_type_options', $field_type_options);
$form_state->set('unique_definitions', $unique_definitions);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.