Drupal 7 gave us alters in the theme layer, so adding attributes to a form item is rather trivial in our themes, no need to build a separate “form alter” mini-module.
This code goes in your template.php file, note this is for the search block only, the advanced search form has a different form_id:
<?php// Add some cool text to the search block form
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == ‘search_block_form’) {
// HTML5 placeholder attribute
$form[‘search_block_form’][‘#attributes’][‘placeholder’] = t(‘enter to search’);
}
}
?>
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == ‘search_block_form’) {
// HTML5 placeholder attribute
$form[‘search_block_form’][‘#attributes’][‘placeholder’] = t(‘enter to search’);
}
}
?>
“enter to search” replace the text with your text.