function webform_bootstrap_preprocess_input in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_bootstrap/webform_bootstrap.module \webform_bootstrap_preprocess_input()
Implements template_preprocess_input().
File
- modules/
webform_bootstrap/ webform_bootstrap.module, line 114 - Helps support Webform to Bootstrap integration.
Code
function webform_bootstrap_preprocess_input(&$variables) {
if (!_webform_bootstrap_is_active_theme()) {
return;
}
$element =& $variables['element'];
// Bootstrap theme does not support image buttons so we are going to use
// Bootstrap's icon buttons.
// @see themes/bootstrap/templates/input/input--button.html.twig
// @see \Drupal\webform\Element\WebformElementStates::buildOperations
// @see \Drupal\webform\Element\WebformMultiple::buildElementRow
if (isset($element['#type']) && $element['#type'] === 'image_button' && strpos($variables['attributes']['src'], '/webform/images/icons/') !== FALSE) {
$element['#icon_only'] = TRUE;
if (strpos($variables['attributes']['src'], '/webform/images/icons/plus.svg') !== FALSE) {
$element['#title'] = t('Add');
$element['#icon'] = \Drupal\bootstrap\Bootstrap::glyphicon('plus-sign');
}
elseif (strpos($variables['attributes']['src'], '/webform/images/icons/minus.svg') !== FALSE) {
$element['#title'] = t('Remove');
$element['#icon'] = \Drupal\bootstrap\Bootstrap::glyphicon('minus-sign');
}
}
}