Redirección de formulario Drupal que evita que se ejecuten múltiples controladores de envío

I have a custom module that has a form which contains a form redirect in the submit handler.

I'm using a hook_form_alter, and appending another custom submit handler, for a total of two submit handlers. The redirect is preventing my second handler from executing. When I remove the redirect, the function works perfectly. Any ideas on how to prevent a redirect from messing up the custom submit handler?

  • I can't change the order of the form alter, meaning I can't have the redirect submit hook be second.
  • I can't put the redirect in the second handler, because it's not concerned with my form alter.

Algún código:

Original form handler
function example_form_handler($form, &$form_state) {
  //some logic to insert into a db and then...
  $form_state['redirect'] = '';

/* Form alter in another file*/
function sm_integration_form_alter(&$form , &$form_state, $form_id) {
   //this is altering the above form.
   if ($form_id == "my_data_form" ){
    //alert the form weight to be populated at last
    $form['submit']['#weight'] = 5;
    $form['#submit'][] =  'sm_integration_enable_submit';


/* This code is not being executed with the redirect */
function sm_integration_enable_submit(&$form, &$form_state) {
 watchdog('sm_integration', 'This code does not execute with the redirect in the original module enabled');

preguntado el 10 de septiembre de 13 a las 00:09

1 Respuestas

Looks like you are trying redirect to the homepage

Specify the homepage(baseurl) $url on the redirect

$form_state['redirect'] = $GLOBALS['base_url'];  

Respondido el 10 de Septiembre de 13 a las 00:09

You're right, having the blank string was causing the problem. Good to know. - Foo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.