What i would do is take it a step back and see if you're even registering this hook. Often $form_id
's change.
Debugging process:
- Turn on devel
- Insert dsm($form_id) inside your hook as you used to with D6
- Clear your cache
Example code (inside mymodule.module
or template.php
file) from drupal.org:
<?php
/**
* Implements hook_form_alter().
*/
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'form_views_exposed_form') {
drupal_set_message("Form ID is : " . $form_id);
}
}
?>
You'll see a bunch of form id's printed out then select your views exposed form hook and work from there.
Also, with drupal 7 you're able to target specific forms by ID directly.
Example:
<?php
/**
* Implements hook_form_alter().
*/
function mymodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
drupal_set_message("Form ID is : " . $form_id);
}
?>
Note that if you're using multiple exposed forms you can check for a specific view by examining $form['#id'] in the form alter function.
Finally, if that doesn't work i would recommend reviewing this issue queue:
How to alter filter in exposed filters form trough form_alter hook