diff -u b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php --- b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php +++ b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php @@ -45,8 +45,12 @@ * The event to process. */ public function onView(GetResponseForControllerResultEvent $event) { - // Ensure this request is rendered as HTML so that we can manage the - // creation of an AJAX response directly in self::onException(). + // To support an AJAX form submission of a form within a block, make the + // later VIEW subscribers process the controller result as though for + // HTML display (i.e., add blocks). During that block building, when the + // submitted form gets processed, an exception gets thrown by + // Drupal\Core\Form\FormBuilderInterface::buildForm(), allowing + // self::onException() to return an AJAX response instead of an HTML one. $request = $event->getRequest(); if ($request->query->has(FormBuilderInterface::AJAX_FORM_REQUEST)) { $request->query->set(MainContentViewSubscriber::WRAPPER_FORMAT, 'html');