Previously, \Drupal\field_ui\Form\FieldStorageAddForm::submit() saved the newly created Field and Field Storage config entities prior to advancing to the forms for editing their settings.
This has been changed to instead store the in-progress data for these entities in the private temp store until the entire field creation workflow (including the FieldStorageConfigEditForm and FieldConfigEditForm forms) has been completed.
This change is not expected to impact any code that's already using the correct APIs for accessing these config entities during new field creation. For example:
- Within field type plugins,
$this->getEntity()continues to work as expected, even before that entity has been saved. - Within
hook_form_field_storage_config_edit_form_alter()implementations,$field_storage = $form_state->getFormObject()->getEntity()continues to work as expected, even before that entity has been saved. - Within
hook_form_field_config_edit_form_alter()implementations,$field = $form_state->getFormObject()->getEntity()and$field_storage = $form_state->getFormObject()->getEntity()->getFieldStorageDefinition()continue to work as expected, even before those entities have been saved.
However, code that attempts to load these entities from the database will fail to do so until these entities have been saved.
For example, this is the recommended way to retrieve the field and field storage objects within hook_form_field_config_edit_form_alter():
hook_form_field_config_edit_form_alter(&$form, $form_state) {
$field = $form_state->getFormObject()->getEntity();
$field_storage = $field->getFieldStorageDefinition();
}
This is not recommended, and no longer works during the field creation workflow:
hook_form_field_config_edit_form_alter(&$form, $form_state) {
...
$field = FieldConfig::loadByName($target_entity_type, $target_bundle, $field_name);
$field_storage = FieldStorageConfig::loadByName($target_entity_type, $field_name);
}