Ajax form. Exposed filter with -Any-
. In hook_form_alter()
i write:
if ($form_id == 'views_exposed_form') {
if ($form_state['view']->name == 'machinery') {
$form['field_producer_tid']['#options']['All'] = t('-All-');
}
$form['field_producer_tid']['#default_value'] = "All";
dsm($form);
}
But default value is the second <option>
from select list. Always. Any value which i assign is ignored. How should i set default value?
According to https://drupal.org/node/1239868 you will have to use some other hook. You can try
/**
* Implements hook_views_pre_build().
*/
function YOUR_MODULE_views_pre_build(&$view) {
if ($view->name == 'machinery') {
$view->filter['field_producer_tid']->value = "All";
}
}
This way, you will be able to choose default value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With