You are here

function _webform_preprocess_options in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.inc \_webform_preprocess_options()

Prepares variables for checkboxes and radios options templates.

Below code must be called by template_preprocess_(radios|checkboxes) which reset the element's 'attributes';

2 calls to _webform_preprocess_options()
webform_preprocess_checkboxes in includes/webform.theme.inc
Implements hook_preprocess_checkboxes() for checkboxes templates.
webform_preprocess_radios in includes/webform.theme.inc
Implements hook_preprocess_radios() for radios templates.

File

includes/webform.theme.inc, line 715
Theme hooks, preprocessor, and suggestions.

Code

function _webform_preprocess_options(array &$variables) {
  $element =& $variables['element'];
  $variables['attributes']['class'][] = Html::getClass('js-webform-' . $element['#type']);
  if (!empty($element['#options_display'])) {
    if (strpos($element['#options_display'], 'buttons_') === 0) {
      $variables['attributes']['class'][] = 'webform-options-display-buttons';
    }
    $variables['attributes']['class'][] = Html::getClass('webform-options-display-' . $element['#options_display']);
    $variables['#attached']['library'][] = 'webform/webform.element.options';
  }
}