I have a FORM built with Drupal 7 Form API, with URL (action) pointing to:


and the default method POST. My SEO mate has asked me to change the method to GET, so for SEO indexing purposes the URL will be explicit, for example:


I have changed the behaviour of the form by adding the following line at the end of the hook_form function:

$form["#method"] = "get";

Now the problem is that the generated URL has some "extra" info that I wouldn't want to be displayed. And it is apparently unnecessary, because if the View (landing page of the FORM) is paged, if I only pass the above parameters + the page, it works perfectly, also if I remove this extra info by hand.

The "ugly" URL is:


(extra info: ... &op=Submit&form_build_id=form-Ab-i8LlsUjtftyuTlL8b7OvZj_tM1MfyuKCnAg5-VncY&form_id=hook_form )

How can I make Drupal ignore that extra info?

| improve this question | | | | |

Here's a workaround you can use:

    $form['#after_build'][] = 'mymodule_form_modify';


    function mymodule_form_modify($form){
      return $form;

And finally to get rid of the &op parameter:

    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
      '#name' => '',


| improve this answer | | | | |
  • Thank you very much, Aram. It works perfect. I will wait for Clive reply to complete the code, regarding FORM security and cache, which of course worries me. – Cesar Feb 23 '16 at 15:17
  • Ignore what I said @Cesar, not enough coffee in me when I came up with that ;) – Clive Feb 23 '16 at 18:18
  • Well, even if you didn't have enough caffeine in blood, you still hit the point: removing the extra parameters make the Ajax not to work properly. So it was needed after all. We commented on this curious AJAX behaviour here, when it still worked as POST: drupal.stackexchange.com/questions/182831/…. Now, changing to GET and removing extra parameters make the whole thing not to work, to my dismay. I guess that the rebuild action cannot be properly done by lack of information. – Cesar Feb 24 '16 at 7:19

You can't, those "extra infos" are required by Drupal to process form submission.

EDIT : Well i have read too fast. If you use a custom action, and thus does not have validate or submit function, you can skip drupal specific parameters. Just add access false to fields you don't want to be submitted.

$form['form_build_id']['#access'] = FALSE;
| improve this answer | | | | |
  • I cannot believe Drupal not to be flexible enough. With thousands of hooks, surely there must be a way. – Cesar Feb 23 '16 at 12:13

No need to do that in Drupal:

You can hide parameters in Google.

Follow Google Webmaster --> Crawl --> URL Parameters, after that click Configure URL parameters » then click add parameters and add parameters which you want not to index in Google.


| improve this answer | | | | |
  • Thanks for the tip. In any case I would like to hide also to the customer. – Cesar Feb 23 '16 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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