Hello,

I am using entityforms on my site, and I am trying to programmatically setup a redirect once a user edits a particular entityform submission. What I mean is, I have a list of entityforms that do various things. I am trying to make it so that when a user submits a submission to say, entityform named 'request', and an admin views the submission and uses the 'edit' link to change the values in the submission, once the settings are saved, the admin is redirect to a custom page, NOT the 'submissions summary' page for that entityform. I've tried using #submit handlers but it appears entityforms does it's own redirection.

Does anybody have a suggestion on what I could do to achieve this ?

Comments

tedbow’s picture

Do you make sure your #submit handler is run last and then add your path to "$form_state['redirect']"?

christianhg’s picture

I think I'm trying to achieve the same as ex0r. I'm using the hook_form_FORM_ID_alter hook to add an additional submit handler. The new submit handler is definitely called after the original but the redirect is ignored.

function custom_module_form_FORM_ID_alter(&$form, &$form_state) {  
  $form['actions']['save']['#submit'][] = 'custom_module_entityform_edit_form_submit';
}

function custom_module_entityform_edit_form_submit() {
  $form_state['redirect'] = 'xxx/xxx';
}
jamestombs’s picture

Custom #submit callbacks are completely ignored.

I've tried adding to $form['#submit'] and $form['actions']['submit']['#submit'] but the function isn't called. I can't see anything in the entityform_edit_form_submit() function that would stop this from working.

Even changing the submit handler using:

$form['actions']['submit']['#submit'] = array('custom_submit_callback');

doesn't work, the function isn't called despite it being the only function set.

drupix’s picture

I have this working like this:

function custom_module_form_FORM_ID_alter(&$form, &$form_state, $form_id) {  
  $form['actions']['save']['#submit'][] = 'custom_module_entityform_edit_form_submit';
}

function custom_module_entityform_edit_form_submit(&$form, &$form_state) {
  $form_state['redirect'] = 'xxx/xxx';
}
salimousavi’s picture

function custom_module_form_FORM_ID_alter(&$form, &$form_state, $form_id) {  
  $form['#submit'][] = 'custom_module_entityform_edit_form_submit';
}

function custom_module_entityform_edit_form_submit(&$form, &$form_state) {
  drupal_goto('PATH');
}