function FormController::getContentResult

Same name in other branches
  1. 9 core/lib/Drupal/Core/Controller/FormController.php \Drupal\Core\Controller\FormController::getContentResult()
  2. 8.9.x core/lib/Drupal/Core/Controller/FormController.php \Drupal\Core\Controller\FormController::getContentResult()
  3. 10 core/lib/Drupal/Core/Controller/FormController.php \Drupal\Core\Controller\FormController::getContentResult()

Invokes the form and returns the result.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

array The render array that results from invoking the controller.

3 methods override FormController::getContentResult()
LayoutBuilderDecorationTestHtmlEntityFormController::getContentResult in core/modules/layout_builder/tests/modules/layout_builder_decoration_test/src/Controller/LayoutBuilderDecorationTestHtmlEntityFormController.php
Invokes the form and returns the result.
LayoutBuilderHtmlEntityFormController::getContentResult in core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php
Invokes the form and returns the result.
WorkspacesHtmlEntityFormController::getContentResult in core/modules/workspaces/src/Controller/WorkspacesHtmlEntityFormController.php
Invokes the form and returns the result.

File

core/lib/Drupal/Core/Controller/FormController.php, line 56

Class

FormController
Common base class for form interstitial controllers.

Namespace

Drupal\Core\Controller

Code

public function getContentResult(Request $request, RouteMatchInterface $route_match) {
    $form_arg = $this->getFormArgument($route_match);
    $form_object = $this->getFormObject($route_match, $form_arg);
    // Add the form and form_state to trick the getArguments method of the
    // controller resolver.
    $form_state = new FormState();
    $request->attributes
        ->set('form', []);
    $request->attributes
        ->set('form_state', $form_state);
    $args = $this->argumentResolver
        ->getArguments($request, [
        $form_object,
        'buildForm',
    ]);
    $request->attributes
        ->remove('form');
    $request->attributes
        ->remove('form_state');
    // Remove $form and $form_state from the arguments, and re-index them.
    unset($args[0], $args[1]);
    $form_state->addBuildInfo('args', array_values($args));
    return $this->formBuilder
        ->buildForm($form_object, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.