Quantcast
Viewing all articles
Browse latest Browse all 293238

Exception handling in FieldBlock.php breaks AJAX forms provided via formatter

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

-


Viewing all articles
Browse latest Browse all 293238

Trending Articles