Posted By

terrencewood on 07/21/09


Tagged

drupal views hookformalter


Versions (?)

hook_form_alter for views exposed filter form


 / Published in: PHP
 

  1. /**
  2.  * Implementation of hook_form_FORM_ID_alter() for 'views exposed form'
  3.  * Change the first option label '<All>' to 'Filter by Identifier Name' for exposed filters
  4.  * The filter identifier needs set up with underscores for multiple word filter names
  5.  * e.g. 'document_type' becomes 'Document Type'
  6.  */
  7.  
  8. function mymodule_form_views_exposed_form_alter (&$form, $form_state) {
  9. foreach($form as $key => &$value) {
  10. if(isset($value['#options']['All'])) {
  11. $label = ucwords(strtolower(str_replace('_', ' ', $key)));
  12. $value['#options']['All'] = t('Filter by !label', array('!label' => $label));
  13. }
  14. }
  15. }

Report this snippet  

You need to login to post a comment.