Problem/Motivation
I found a regression caused by the Field UI changes in the Geocoder module: #3410082: TypeError on Drupal 10.2.0. 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
Issue fork drupal-3410183
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments