Skip to main content
2 of 2
added 1179 characters in body
Shyghar
  • 1.1k
  • 16
  • 30

correct url() request

I need to make a redirect after a customer added something to his cart so I write this:

function MODULE_form_alter(&$form, &$form_state, $form_id) {
  array_push($form['#submit'], '_MODULE_redirect_to_products');
}

function  _MODULE_redirect_to_products(&$form, &$form_state){
  global $language ;

  $form_state['redirect'] = url('prodotti', array('language' => $language));
}

but this code redirect me to

/dev/azzurra/?q=it//dev/azzurra/%3Fq%3Dit/prodotti

but I need to redirect to

/dev/azzurra/?q=it/prodotti

according to the language obviously.

UPDATE: I'm try to use

 $form_state['redirect']

but if I display this field before modify it I can see this

Array
(
    [0] => prodotti
    [1] => Array
        (
            [language] => stdClass Object
                (
                    [language] => it
                    [name] => Italian
                    [native] => Italiano
                    [direction] => 0
                    [enabled] => 1
                    [plurals] => 2
                    [formula] => ($n!=1)
                    [domain] => 
                    [prefix] => it
                    [weight] => 0
                    [javascript] => a97-0F_JBbaSYaN4XQBbFbhCLCysRpSabTcDmQjB73E
                    [provider] => locale-url
                )

        )

    [2] => 302
)

but the form redirect me to 'it/testate/name' because the form 'add product' is displayed in a view so I think that the views module override the $form_state['redirect'] after me so the default redirect [and mine one..].

I think I can't use this kind of redirect.. How can I achieve this redirect correctly?

Shyghar
  • 1.1k
  • 16
  • 30