function FormPreprocess::preprocessRadios

Prepares variables for radios templates.

Default template: radios.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes, #children.

File

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

Class

FormPreprocess
Initial preprocess callbacks for the form system.

Namespace

Drupal\Core\Form

Code

public function preprocessRadios(array &$variables) : void {
  $element = $variables['element'];
  $variables['attributes'] = [];
  if (isset($element['#id'])) {
    $variables['attributes']['id'] = $element['#id'];
  }
  if (isset($element['#attributes']['title'])) {
    $variables['attributes']['title'] = $element['#attributes']['title'];
  }
  $variables['children'] = $element['#children'];
}

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