I have a custom module where I'm changing some values, etc... My exposed filters search does not work when the user leaves the title field as 'Search by Address, City, State, or Zip'... I want to check for this value when the user clicks the submit button... If it finds it, I want to set it to blank... Where can I override this functionality?

	function exposedviewsformalter_form_alter(&$form, $form_state, $form_id) 
	{
		$form['title']['#value'] = 'Search by Address, City, State, or Zip';
            	$form['title']['#attributes']= array('onfocus' => "if (this.value == 'Search by Address, City, State, or Zip') {this.value = '';}", 'onblur' => "if (this.value == '') {this.value = 'Search by Address, City, State, or Zip';}");
		$form['title']['#size'] = '48';
}

Comments

scrypter’s picture

you want to do this using javascript, you could add an onsubmit to the form. I am fairly sure the form alter can do this. You can control whether the form submits to the server or not by returning true or false.

If you want to handle all this on the server, you could use the form_alter to set the '#submit" to call your own php function and massage the $form[] values.

www.purpleoar.co.nz/scryptik - Javascript editor with syntax error checking
www.purpleoar.co.nz - Web development, Drupal consultancy

manderson311’s picture

To be honest, it doesn't matter how I do this... Javascript or whatever. I think I may lean towards some type of override of a function so that I can dig around in Drupal, but whatever gets the job done works.

I tried using onsubmit where the onfocus/onblur is, but it wasn't work. I used an if to check the title value, then I tried changing the value to ''...

prakashp’s picture

1. In your form_alter function add a custom validate function.
2. In your custom validate function, check the $form_state['values'], if its the value you're looking for, use form_set_value to set it to blank.