Exposed form don't have class attribute In a form_alter, I simply want to add a class to an exposed form (this code works for a custom form) : 

$form['#attributes']['class'][] = 'my_class';


But neither my class nor the default class (views-exposed-form, I can see it in $form['#attributes']) is printed in front in the form tag. 

Any idea?
I guess hook_form_alter is not the right place to set attributes. But I may be wrong. What surely works is to set attributes in a preprocess function.

The following snippet adds the form ID as CSS class to every form. You could easily wrap some if-request around this to only fire on certain forms checking for $variables['element']['#form_id'].

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_form(&amp;$variables) {

  // Add form ID as class to form attributes.
  $variables['attributes']['class'][] = 'form';
  $variables['attributes']['class'][] = 'form-' . str_replace('_', '-', $variables['element']['#form_id']);
}