Search code examples
formsdrupaldrupal-7search-form

Where is the search-theme-form.tpl.php file located in a drupal site or template?


In Drupal (my one is v. 7), in a search module, the text "search" in search button is viewing by default. Probably the HTML structure behind this thing is like this:

<input type="submit" value="Search"  />

I placed an image instead of the default search button image/bg color. I want to delete the value="Search" portion from the HTML <input/> tag.

I went to modules/search, but there is no such file with a <input/> tag. So how come I remove the text?

I got a solution, my so called 'Bangla Shamadhan', from http://mydrupalblog.lhmdesign.com/theming-search-submit-button-css-cross-browser-compatible-solution.

It's the text-indent thing:

#search-block-form input.form-submit, #search-form input.form-submit {
  height: 24px;
  width: 24px;
  cursor: pointer;
  text-indent: -9999px;
  border: none;
  background: url(images/mag_glass.jpg) no-repeat left top;
}

The text is indented for unlimited spaces. It worked for me, but it's not a good practice to me.

enter image description here

So, how can I edit the <input/> tag in a Drupal template or module to remove the attribute value="Search"?**


Solution

  • I think hook_form_alter() is what you need in this case:

    function mymodule_form_alter(&$form, $form_state, $form_id) {
      if($form_id=='search_form') {
        $form['basic']['inline']['submit']['#value'] = '';  // OR
        unset($form['basic']['inline']['submit']['#value']);
      }
    }