I am here again with a problem! I want to make a form redirect usign a url with ids and somethings else as parameter, but when the code is executed something encode my url, so, if I put something like this $form_state['redirect'] = "page=$nid"; I get this in the url "page*%3D*123456789" %3D is the =$. So, how i have to do that? I tested with utf8_encode too.

Can I use a drupal_goto() inside a form? Why yes? Why not?

Thanks people!

  • When do you want to redirect a page? do you want redirection when the form submission? If so, you can use drupal_goto() on submit callback. – sathishkumar Mar 20 '12 at 17:34
  • 2
    @sathishkumar To redirect a form from its form submission handler, you should use $form_state['redirect']. – kiamlaluno Mar 20 '12 at 17:50

What you set in $form_state['redirect'] can be:

  • a string containing the destination, such as node/1, admin/reports/status, or user/1.
  • an array of arguments compatible with drupal_goto().

The examples shown in drupal_redirect_form() are the following ones:

  • This redirect the form to node:

    $form_state['redirect'] = 'node';
  • This redirect the form to node/123?foo=bar#baz:

    $form_state['redirect'] = array(
        'query' => array(
          'foo' => 'bar',
        'fragment' => 'baz',

In your case, if you want to redirect to page/$nid, you should use the following code:

$form_state['redirect'] = "page/$nid";

If you really want to redirect to page=$nid, then you should use the following code:

$form_state['redirect'] = array(
    'query' => array(
      'page' => $nid,
  • 4
    It might be worth mentioning that if destination is set in the URL query string then setting $form_state['redirect'] won't have any effect as Drupal will ignore it in favour of the destination arg. – Clive Mar 20 '12 at 18:13

How to achieve,the below issue in drupal SAVE and NEW button.

If I want out of ten fields the top four fields of the same form to be pre filled again with the same data as I click on the submit button.

Thanks In Advance.

  • This don't answer OP's question. – Felix Eve Apr 8 '14 at 10:36
  • As the matter of fact its not a answer of the above statements It's a query which i asked ......as the trailing above things are somewhat related to the same am asking about...... So, Only i posted over here – user3500549 Apr 9 '14 at 5:44

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.