تغییر خصوصیات فرم جستجوی دروپال

با افزودن کد زیر در template.php  تم خود می توانید خصوصیاتی از قبیل placeholder  و ... را به فرم جستجوی دروپال  بیافزایید

function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
 if ($form_id == 'search_block_form') {
     $form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
     $form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
     $form['search_block_form']['#size'] = 40;  // define size of the textfield
     $form['search_block_form']['#default_value'] = t(''); // Set a default value for the textfield
     $form['actions']['submit']['#value'] = t(''); // Change the text on the submit button
     $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/');
       // Add extra attributes to the text box
     $form['search_block_form']['#attributes']['onblur'] = "";
     $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'); return false; }";
    // Alternative (HTML5) placeholder attribute instead of using the javascript
    $form['search_block_form']['#attributes']['placeholder'] = t('Search for somthing here');
}

و در آخر برای ذخیره تغییرات

function THEMENAME_preprocess_search_block_form(&$vars) {
  $vars['search_form'] = str_replace('type="text"', 'type="search"', $vars['search_form']);
}
درخت مرجع: 

افزودن نظر جدید