Problem/Motivation
Hello, The FieldBlock.php block plugin (field_block) from layout_builder, which is used to display entity fields, does not throw a FormAjaxException, so AJAX forms provided from field formatters are not submitted.
Steps to reproduce
Create a formatter that provides an AJAX form, try to submit it, you will get the error: The field "field_name" failed to render with the error of "".
It is also necessary that in the entity_view_display configuration, this field should not be in the content section, since LayoutBuilderEntityViewDisplay::buildMultiple calls the parent EntityViewDisplay::buildMultiple, which duplicates the formatter view call, thereby skipping exceptions before it gets to FieldBlock.php.
Proposed resolution
Throw a FormAjaxException exception in the same way as you would with an EnforcedResponseException exception.
Remaining tasks
Fix.- Test coverage.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
-
Issue fork drupal-3459376
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
Comment #3
kksandr commentedComment #4
kksandr commentedComment #5
kksandr commentedI made the error message more descriptive using "Error::logException()". This will be useful because some exceptions do not have a message (as in the case of "FormAjaxException") and their cause is implied in the name of the exception class.