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

  1. Fix.
  2. Test coverage.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

-

Issue fork drupal-3459376

Command icon 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

kksandr created an issue. See original summary.

kksandr’s picture

Assigned: kksandr » Unassigned
Status: Active » Needs work
Issue tags: +Needs tests
kksandr’s picture

Issue summary: View changes
kksandr’s picture

I 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.