Radio::preRenderRadio

public static Radio::preRenderRadio($element)

Prepares a #type 'radio' render element for input.html.twig.

Parameters

array $element: An associative array containing the properties of the element. Properties used: #required, #return_value, #value, #attributes, #title, #description. The #name property will be sanitized before output. This is currently done by initializing Drupal\Core\Template\Attribute with all the attributes.

Return value

array The $element with prepared variables ready for input.html.twig.

File

core/lib/Drupal/Core/Render/Element/Radio.php, line 53

Class

Radio
Provides a form element for a single radio button.

Namespace

Drupal\Core\Render\Element

Code

public static function preRenderRadio($element) {
  $element['#attributes']['type'] = 'radio';
  Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  static::setAttributes($element, array('form-radio'));

  return $element;
}
doc_Drupal
2016-10-29 09:36:16
Comments
Leave a Comment

Please login to continue.