I have a section in my theme where I'd like to manually include a search input. I do not want to use the search block as I have some additional customizations I'm integrating outside of the scope of this question.

It looks like the default search form posts to the existing page and redirects to the results page (/search/node/query). How can I manually trigger this to happen?

I've tried to mimic the form_id but it doesn't seem to pick it up:

<form method="post" action="">
    <input type="text" name="search_block_form" ng-model="query" />
    <input type="submit" value="Search" />

    <input type="hidden" name="form_token" value="">
    <input type="hidden" name="form_id" value="search_block_form">

There is an additional field in the default block called form_build_id but it changes each time the form is rendered.

How can I accomplish manually creating a POST to go to search results?

1 Answer 1


Drupal core search result pages do not listen to URL Parameters or HTTP POST content. Instead, it takes the third part from the search/node/QUERY URL format, and shows results for QUERY.

This unfortunately makes it not possible to use a standard HTML form created without Drupal's form API. There are of course workarounds.

Basically what we try to do is route the user's search query to the search/node path. I can see you are using Angular. You might be able to make it send the user to the proper path.

Alternately, you can make Drupal listen to URL parameters or the HTTP post request content.

https://www.drupal.org/project/query_parameters_to_url - this module I just found (and did not try personally) appears to rewrite URL parameters to a path query. I'm not sure this will work for search forms though.

If not, you will have to create a custom module, and take over the search result page callback. Then, it can show appropriate results or call the old page callback function with the search query taken from alternative sources.

  • 1
    Thank you for the info, and nice observation on using angular. My goal was to provide a fallback for non-Javascript enabled submission by just submitting the form, but it looks like unfortunately I will have to create a module and another unnecessary redirect just to do this. I am otherwise using Angular to redirect users directly to the appropriate page without an additional redirect.
    – Ryan
    Feb 4, 2016 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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