I have a simple form

function example_form($form, &$form_state) {
  $form['#attributes']['method'] = 'get';
  $form['button'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  $form['search'] = array(
    '#type' => 'textfield',
    '#required' => FALSE,

  return $form;

and a submit handler

function example_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  drupal_set_message(t('Form Submitted'));

When I click the button, the form submits properly and the URL gets all the form parameters.

but when I reload the page with all those URL parameters, the example_form_submit() is not firing, how do I make my form submit/fire the submit hook when the URL is reloaded with GET parameters?

  • No matter what your submit settings are (GET/POST), it should not trigger the submit handler after a page reload with the same data. A form rendered using the form API adds a submit token to the form that is valid only for that form submission. After a form submit/rebuild (or with a page refresh), the token will be different. So any data transmitted using a browser refresh after the original form was submitted already should not trigger the submit handlers for that form again. (Consider it Drupal's CSRF protection.) Commented Aug 9, 2018 at 12:46

1 Answer 1


The correct way to change the method to be used by a form is to use the #method element rather than by setting the attribute, as otherwise the form API will still expect to be triggered by a POST.


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.