I like the way Joomla's search box works and would like to implement that same, which means I need to add javascript to the search text box.
I had assume (to prove I tried) that the following would work, starting at line 1026 of search.module:
/**
* Output a search form for the search block and the theme's search box.
*/
function search_box($form_id = 'search_theme_form') {
// Use search_keys instead of keys to avoid ID conflicts with the search block.
$form[$form_id .'_keys'] = array(
'#type' => 'textfield',
'#size' => 15,
'#default_value' => 'Search ...',
'#attributes' => array('title' => t('Enter the terms you wish to search for.'), 'onblur' => '"if(this.value==' . "'') this.value='Search...';", 'onfocus' => '"if(this.value==' . "'Search...') this.value='';"'),
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
return drupal_get_form($form_id, $form, 'search_box_form');
}
HOWEVER, this does not work. Is there an easier way that I am just missing? Any input would be greatly appreciated.
Comments
hook_form_alter
Not really a solution to your specific problem but you don't need to edit the module code directly. You can use hook_form_alter. Also, for future reference you should place php code in
<?php ?>tags , makes it a lot easier to read.Thanks
That looks like what I am after ... where do I insert that function?
module
You will need to put it in a module.