0

I’ve activated the search form block on my Drupal home page.

When a user enters a keyword and presses search button, I would like to redirect to the search page result.

How can I do that?

closed as unclear what you're asking by Shawn Conn, Krishna Mohan, Mołot, Scott Joudry, Bala Nov 9 '15 at 13:28

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you explain what you mean by "validate button"? What sort of redirection do you need, as submitting the search form will automatically direct the user to the search results page. – Hendrik Nov 6 '15 at 0:29
1
function MyModuleName_form_alter(&$form, &$form_state, $form_id)
{
   if ($form_id == 'search_form_id') {
     $form['#submit'][] = 'MyModuleName_custom_serch_form_submit';
   }  
} 

function MyModuleName_custom_serch_form_submit($form, &$form_state)
{
  if(isset($_GET['q']) && !empty($_GET['q']))
  {    
     $string_serch= $_GET['q'];
    drupal_goto("http://yourdomain.com/search?q=".$string_serch);
  }
}
1

You can redirect search result by using hook_search_box_form_submit

function mytheme_search_box_form_submit($form, &$form_state) {
   $form_state['#redirect'] = 'path of redirect';
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.