public function HtmlFormController::content

Controller method for generic HTML form pages.

Parameters

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

callable $_form: The name of the form class for this request.

Return value

\Symfony\Component\HttpFoundation\Response A response object.

1 call to HtmlFormController::content()
HtmlEntityFormController::content in drupal/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php
Due to reflection, the argument must be named $_entity_form. The parent method has $request and $_form, but the parameter must match the route.
1 method overrides HtmlFormController::content()
HtmlEntityFormController::content in drupal/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php
Due to reflection, the argument must be named $_entity_form. The parent method has $request and $_form, but the parameter must match the route.

File

drupal/core/lib/Drupal/Core/Controller/HtmlFormController.php, line 48
Contains \Drupal\Core\Controller\HtmlFormController.

Class

HtmlFormController
Wrapping controller for forms that serve as the main page body.

Namespace

Drupal\Core\Controller

Code

public function content(Request $request, $_form) {
  $form_object = $this
    ->getFormObject($request, $_form);

  // Using reflection, find all of the parameters needed by the form in the
  // request attributes, skipping $form and $form_state.
  // At the form and form_state to trick the getArguments method of the
  // controller resolver.
  $form_state = array();
  $request->attributes
    ->set('form', array());
  $request->attributes
    ->set('form_state', $form_state);
  $args = $this->container
    ->get('controller_resolver')
    ->getArguments($request, array(
    $form_object,
    'buildForm',
  ));
  unset($args[0], $args[1]);
  $request->attributes
    ->remove('form');
  $request->attributes
    ->remove('form_state');
  $form_state['build_info']['args'] = $args;
  $form_id = _drupal_form_id($form_object, $form_state);
  return drupal_build_form($form_id, $form_state);
}