Return to Snippet

Revision: 15967
at July 21, 2009 19:29 by terrencewood


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

Initial URL

                                

Initial Description

                                

Initial Title
hook_form_alter for views exposed filter form

Initial Tags
drupal

Initial Language
PHP