function FormBuilder::renderFormTokenPlaceholder

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Form/FormBuilder.php \Drupal\Core\Form\FormBuilder::renderFormTokenPlaceholder()
  2. 8.9.x core/lib/Drupal/Core/Form/FormBuilder.php \Drupal\Core\Form\FormBuilder::renderFormTokenPlaceholder()
  3. 10 core/lib/Drupal/Core/Form/FormBuilder.php \Drupal\Core\Form\FormBuilder::renderFormTokenPlaceholder()

Renders the form CSRF token. It's a #lazy_builder callback.

Parameters

string $placeholder: A string containing a placeholder, matching the value of the form's #token.

Return value

array A renderable array containing the CSRF token.

File

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

Class

FormBuilder
Provides form building and processing.

Namespace

Drupal\Core\Form

Code

public function renderFormTokenPlaceholder($placeholder) {
    return [
        '#markup' => $this->csrfToken
            ->get($placeholder),
        '#cache' => [
            'contexts' => [
                'session',
            ],
        ],
    ];
}

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