/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function yourtheme_preprocess_search_block_form(&$vars, $hook) { // Modify elements of the search form // Set a default value for the search box $vars['form']['search_block_form']['#value'] = t('Search this site'); // Add a custom class to the search box // Set yourtheme.css > #search-block-form .form-text { color: #888888; } 'onblur' => "if (this.value == '') {this.value = '".$vars['form']['search_block_form']['#value']."';} this.style.color = '#000000';", 'onfocus' => "if (this.value == '".$vars['form']['search_block_form']['#value']."') {this.value = '';} this.style.color = '#000000';" ); // Modify elements of the submit button // Change text on the submit button //$vars['form']['submit']['#value'] = t('Go!'); // Change submit button into image button - NOTE: '#src' leading '/' automatically added $vars['form']['submit']['image_button'] = array('#type' => 'image_button', '#src' => 'sites/all/themes/yourtheme/images/search-button.png'); // Rebuild the rendered version (search form only, rest remains unchanged) $vars['search']['search_block_form'] = drupal_render($vars['form']['search_block_form']); // Rebuild the rendered version (submit button, rest remains unchanged) $vars['search']['submit'] = drupal_render($vars['form']['submit']); // Collect all form elements to print entire form }
URL: http://drupal.org/node/154137