function FormPreprocess::preprocessInput

Prepares variables for input templates.

Default template: input.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #attributes.

File

core/lib/Drupal/Core/Form/FormPreprocess.php, line 216

Class

FormPreprocess
Initial preprocess callbacks for the form system.

Namespace

Drupal\Core\Form

Code

public function preprocessInput(array &$variables) : void {
  $element = $variables['element'];
  // Remove name attribute if empty, for W3C compliance.
  if (isset($variables['attributes']['name']) && empty((string) $variables['attributes']['name'])) {
    unset($variables['attributes']['name']);
  }
  $variables['children'] = $element['#children'];
}

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