template_preprocess_form

template_preprocess_form(&$variables)

Prepares variables for form templates.

Default template: form.html.twig.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #action, #method, #attributes, #children

File

core/includes/form.inc, line 352
Functions for form and batch generation and processing.

Code

function template_preprocess_form(&$variables) {
  $element = $variables['element'];
  if (isset($element['#action'])) {
    $element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
  }
  Element::setAttributes($element, array('method', 'id'));
  if (empty($element['#attributes']['accept-charset'])) {
    $element['#attributes']['accept-charset'] = "UTF-8";
  }
  $variables['attributes'] = $element['#attributes'];
  $variables['children'] = $element['#children'];
}
doc_Drupal
2016-10-29 09:46:41
Comments
Leave a Comment

Please login to continue.