Commit f676f205 authored by Roman Gudev's avatar Roman Gudev Committed by Alberto Siles
Browse files

Issue #3261777 by super_romeo: is-invalid class does not added to selectboxes

parent 6ca04ee8
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -731,3 +731,22 @@ function bootstrap_barrio_preprocess_input(&$variables) {
    $variables['safe_value_label'] = Xss::filter($variables['attributes']['value']);
  }
}


/**
 * Implements hook_preprocess_select() for adding classes to select boxes.
 */
function bootstrap_barrio_preprocess_select(&$variables) {
  if (isset($variables['attributes']['class'])) {
    if (is_object($variables['attributes']['class'])) {
      if (in_array('error', $variables['attributes']['class']->value())) {
        $variables['attributes']['class']->addClass('is-invalid');
      }
    }
    elseif (is_array($variables['attributes']['class'])) {
      if (in_array('error', $variables['attributes']['class'])) {
        $variables['attributes']['class'][] = 'is-invalid';
      }
    }
  }
}