FormBuilder::buildFormAction

protected FormBuilder::buildFormAction()

Builds the $form['#action'].

Return value

string The URL to be used as the $form['#action'].

File

core/lib/Drupal/Core/Form/FormBuilder.php, line 828

Class

FormBuilder
Provides form building and processing.

Namespace

Drupal\Core\Form

Code

protected function buildFormAction() {
  // @todo Use <current> instead of the master request in
  //   https://www.drupal.org/node/2505339.
  $request = $this->requestStack->getMasterRequest();
  $request_uri = $request->getRequestUri();

  // Prevent cross site requests via the Form API by using an absolute URL
  // when the request uri starts with multiple slashes..
  if (strpos($request_uri, '//') === 0) {
    $request_uri = $request->getUri();
  }

  // @todo Remove this parsing once these are removed from the request in
  //   https://www.drupal.org/node/2504709.
  $parsed = UrlHelper::parse($request_uri);
  unset($parsed['query'][static::AJAX_FORM_REQUEST], $parsed['query'][MainContentViewSubscriber::WRAPPER_FORMAT]);
  return $parsed['path'] . ($parsed['query'] ? ('?' . UrlHelper::buildQuery($parsed['query'])) : '');
}
doc_Drupal
2016-10-29 09:15:22
Comments
Leave a Comment

Please login to continue.