class FormAjaxResponseBuilder implements FormAjaxResponseBuilderInterface (View source)

Builds an AJAX form response.

Given the current request, a form render array, its form state, and any AJAX commands to apply to the form, build a response object.

Properties

protected MainContentRendererInterface $ajaxRenderer

The main content to AJAX Response renderer.

protected RouteMatchInterface $routeMatch

The current route match.

Methods

__construct(MainContentRendererInterface $ajax_renderer, RouteMatchInterface $route_match)

Constructs a new FormAjaxResponseBuilder.

buildResponse(Request $request, array $form, FormStateInterface $form_state, array $commands)

Builds a response for an AJAX form.

Details

__construct(MainContentRendererInterface $ajax_renderer, RouteMatchInterface $route_match)

Constructs a new FormAjaxResponseBuilder.

Parameters

MainContentRendererInterface $ajax_renderer

The ajax renderer.

RouteMatchInterface $route_match

The current route match.

AjaxResponse buildResponse(Request $request, array $form, FormStateInterface $form_state, array $commands)

Builds a response for an AJAX form.

Parameters

Request $request

The current request.

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

array $commands

An array of AJAX commands to apply to the form.

Return Value

AjaxResponse

An AJAX response representing the form and its AJAX commands.

Exceptions

HttpException