Adding class to form element via hook_form_alter for views exposed filter is not working I have a Views exposed filter, for which I am trying to add a class via hook_form_alter() with the following code:

$form['price']['#attributes'] = array('class' =&gt; array('price-hide'));


Outputting the form array with devel shows that this is adding the attribute fine; however I can only assume there is another hook_form_alter() running after my module that is wiping my attributes, as other attributes are being added, and mine never make it to the HTML output.

I've tried moving from hook_form_alter() to hook_form_views_exposed_form_alter() since I remember that hook running at a different time than hook_form_alter(); however, this doesn't seem to make any difference.
Did you check the actual markup after the page is rendered with Firebug or something to see for sure if another module's hook_form_alter() is overriding yours? If that is indeed the case then an easy way to get around is it by increasing your module's weight so hook_form_alter() in your module is called after other modules.

db_query("UPDATE {system} SET weight = 20 WHERE name = 'my_module'");


EDIT: I should say that this code should go in hook_install() and you should then reinstall your module to get the weight set properly.