webform-element.vars.php 1004 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @file
  4. * Stub file for "webform_element" theme hook [pre]process functions.
  5. */
  6. /**
  7. * Pre-processes variables for the "webform_element" theme hook.
  8. *
  9. * See theme function for list of available variables.
  10. *
  11. * @see theme_webform_element()
  12. *
  13. * @ingroup theme_preprocess
  14. */
  15. function bootstrap_preprocess_webform_element(&$variables) {
  16. $element = $variables['element'];
  17. $wrapper_attributes = array();
  18. if (isset($element['#wrapper_attributes'])) {
  19. $wrapper_attributes = $element['#wrapper_attributes'];
  20. }
  21. // See http://getbootstrap.com/css/#forms-controls.
  22. if (isset($element['#type'])) {
  23. if ($element['#type'] === 'radio') {
  24. $wrapper_attributes['class'][] = 'radio';
  25. }
  26. elseif ($element['#type'] === 'checkbox') {
  27. $wrapper_attributes['class'][] = 'checkbox';
  28. }
  29. elseif ($element['#type'] !== 'hidden') {
  30. $wrapper_attributes['class'][] = 'form-group';
  31. }
  32. }
  33. $variables['element']['#wrapper_attributes'] = $wrapper_attributes;
  34. }