Change record status: 
Project: 
Introduced in branch: 
10.2.x
Introduced in version: 
10.2.0
Description: 

The \Drupal\field_ui\Form\FieldStorageConfigEditForm is now rendered as a subform within \Drupal\field_ui\Form\FieldConfigEditForm. This structural change allows for a more streamlined configuration experience. However, this restructuring necessitates updates in form alters and field configuration updates.

\Drupal\field\FieldConfigStorage needs to be updated during changes made in the field config edit form to ensure that the field config edit form reflects the most up-to-date field storage configuration. In other words, it is no longer sufficient to rely solely on hook_field_storage_config_update to update the field configuration entity when changes are made to field storage.

Modules that rely on hook_field_storage_config_update should now consider incorporating additional logic to update the corresponding field configuration when field storage changes occur within \Drupal\field_ui\Form\FieldConfigEditForm. This ensures that field configuration stays synchronized with field storage configuration.

The hook_form_field_storage_config_edit_form_alter() is deprecated and should be replaced by hook_form_field_config_edit_form_alter(). The storage settings are now nested within $form['field_storage']['subform'].

Old code:

<?php
/**
 * Implements hook_form_FORM_ID_alter() for field_storage_config_edit_form.
 */
function options_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state) {
  $table = &NestedArray::getValue($form, ['settings', 'allowed_values', 'table']);
  $table['#attributes']['class'][] = 'allowed-values-table';
}

New code:

<?php
/**
 * Implements hook_form_FORM_ID_alter() for field_config_edit_form.
 */
function options_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {
  $table = &NestedArray::getValue($form, ['field_storage', 'subform', 'settings', 'allowed_values', 'table']);
  $table['#attributes']['class'][] = 'allowed-values-table';
}

Altering the cardinality field

If a field type needed to make modifications to the cardinality field, it was commonly done using a form alter. It's now possible to do this in \Drupal\Core\Field\FieldItemInterface::storageSettingsForm.

#states API on \Drupal\field_ui\Form\FieldStorageConfigEditForm

The form structure has changed, which results in changes to the data-drupal-selector, id and name attribute values. Any selectors targeting these in #states API, JavaScript or CSS will need to update.

Ajax handlers on \Drupal\field_ui\Form\FieldStorageConfigEditForm

In order for the two forms to remain in sync, the form is updated using AJAX whenever changes to the values of the \Drupal\field_ui\Form\FieldStorageConfigEditForm fields are being made. Since a form element can contain single AJAX event listener, modules using #ajax on form elements within \Drupal\field_ui\Form\FieldStorageConfigEditForm, including those returned by \Drupal\Core\Field\FieldItemInterface::storageSettingsForm may need to manually trigger the form update. This can be done by triggering \Drupal\field_ui\Form\FieldConfigEditForm::fieldStorageSubmit submit handler and by doing a full re-render of the complete form after the AJAX event.

Impacts: 
Site builders, administrators, editors
Module developers