Projet

Général

Profil

Paste
Télécharger (1,09 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / templates / webform / webform-element.vars.php @ eefc2ac0

1
<?php
2

    
3
/**
4
 * @file
5
 * Stub file for "webform_element" theme hook [pre]process functions.
6
 */
7

    
8
/**
9
 * Pre-processes variables for the "webform_element" theme hook.
10
 *
11
 * See theme function for list of available variables.
12
 *
13
 * @param array $variables
14
 *   An associative array of variables, passed by reference.
15
 *
16
 * @see theme_webform_element()
17
 *
18
 * @ingroup theme_preprocess
19
 */
20
function bootstrap_preprocess_webform_element(array &$variables) {
21
  $element = $variables['element'];
22
  $wrapper_attributes = array();
23
  if (isset($element['#wrapper_attributes'])) {
24
    $wrapper_attributes = $element['#wrapper_attributes'];
25
  }
26

    
27
  // See https://getbootstrap.com/docs/3.3/css/#forms-controls.
28
  if (isset($element['#type'])) {
29
    if ($element['#type'] === 'radio') {
30
      $wrapper_attributes['class'][] = 'radio';
31
    }
32
    elseif ($element['#type'] === 'checkbox') {
33
      $wrapper_attributes['class'][] = 'checkbox';
34
    }
35
    elseif ($element['#type'] !== 'hidden') {
36
      $wrapper_attributes['class'][] = 'form-group';
37
    }
38
  }
39

    
40
  $variables['element']['#wrapper_attributes'] = $wrapper_attributes;
41
}