Last active
May 23, 2018 17:44
-
-
Save marisqaporter/c6a5e67de25bd002a2e6cd8a794cb554 to your computer and use it in GitHub Desktop.
to change the search words in drupal search form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*replace Drupal.hermio.setInputPlaceHolder('search_block_form', 'Keywords', '#search-block-form'); */ | |
/*with */ | |
Drupal.hermio.setInputPlaceHolder('search_block_form', 'Search', '#search-block-form'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* marisa's hook_form_FORM_ID_alter | |
*CHANGE THE NAME OF THE THEME IN THE FUNCTION | |
*/ | |
function jvn6_form_search_block_form_alter(&$form, &$form_state, $form_id) { | |
// Add extra attributes to the text box | |
$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search';}"; | |
$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search') {this.value = '';}"; | |
// Prevent user from searching the default text | |
$form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='Search'){ alert('Please enter a search phrase.'); return false; }"; | |
// Alternative (HTML5) placeholder attribute instead of using the javascript | |
$form['search_block_form']['#attributes']['placeholder'] = t('Search'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment