Field config edit form handles form state changes inconsistently

Created on 21 December 2023, 6 months ago

Problem/Motivation

I found a regression caused by the Field UI changes in the Geocoder module: 🐛 TypeError on Drupal 10.2.0 Fixed . As I debugged that, I realized that the problem was caused by the fact that Geocoder added its validator after the ::validateForm, meaning that the form state changes it makes are not taken into account when rebuilding the entity for the form rebuild. We didn't notice this earlier because on form submit, the entity is built with the correct form state. This is possible thanks to the fact that the entity is rebuilt again in \Drupal\Core\Entity\EntityForm::submitForm.

Looking at \Drupal\Core\Form\FormBuilder::processForm, it looks like the Form API doesn't have any API that would allow intersecting between the form rebuild and validation. In the case of the Geocoder module, the solution seems as simple as running the validator before ::validateForm. This doesn't remove the fact that this is highly confusing and brittle.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Field 

Last updated about 7 hours ago

Created by

🇫🇮Finland lauriii Finland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024