Save FieldStorageConfig at the same time as FieldConfig

Created on 3 May 2023, over 1 year ago
Updated 31 August 2023, over 1 year ago

Problem/Motivation

During the field creation flow, you first configure the "Field Storage Settings" and then are redirected to configure the "Field Settings". However, after the first step, the Field Storage is saved. If you abandon the flow at this point, it can be confusing to realize that the field name is now reserved, and to add it as a field, you'd have to go through the "re-use" workflow.

Steps to reproduce

Proposed resolution

  1. Do not save the FieldStorageConfig until the final step (\Drupal\field_ui\Form\FieldConfigEditForm)
  2. Adjust the \Drupal\field\Entity\FieldConfig to not remove unsaved instances of \Drupal\Core\Field\FieldConfigBase::$fieldStorage during serialization because the unsaved instance cannot be recreated from database on unserialize
  3. Adjust button values to make it clear that creating a field is multi-step process

Remaining tasks

User interface changes

API changes

At the moment, \Drupal\field_ui\Form\FieldStorageAddForm saves both FieldStorageConfig and FieldConfig in the beginning of the process, and redirects user to the edit forms of both config entities.

To facilitate the multistep form, we need to store data that has been entered on the previous steps somewhere. This data is stored in the private temp store. The data from the temp store are used later to save both of the config entities in \Drupal\field_ui\Form\FieldConfigEditForm::save.

The temp storage contains an instance of \Drupal\field\Entity\FieldStorageConfig, as well as an array containing settings for the field config. The field config entity is only created before rendering the form because otherwise the objects may get out of sync on serialization. This can be cleaned up in 📌 Combine field storage and field instance forms Fixed .

There's also an API addition in \Drupal\Core\Field\FieldItemList::defaultValueWidget for \Drupal\field_ui\Controller\FieldConfigAddController::fieldConfigAddConfigureForm to provide settings for the entity form display. This allows the default value widget to use widget from pre-configured fields for setting default value.

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

11.0 🔥

Component
Field UI 

Last updated about 1 month ago

Created by

🇺🇸United States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
  • Field UX

    Usability improvements related to the Field UI

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024