Hi

We'd like to change redirect paths with hook_form_alter, but as it seems $form_state['redirect'] gets overwritten in entityform_edit_form_submit() in any case.

Is there anything that would prevent a check wether $form_state['redirect'] is already set in entityform_edit_form_submit()?

We'd be happy to provide a patch. :-)

Cheers
Johnny

Comments

tedbow’s picture

I can't think of anything off the top of my head.

I would be interested in the patch.

Thanks

dansanjou’s picture

Category: feature » bug
StatusFileSize
new811 bytes
new62.2 KB

Similar issue: it looks like in the case of an "edit" and not a "submit" the Redirect path that you select is overwritten in all cases in entityform_edit_form_submit()...

Here's a small patch that makes it work on "submit" when you fill in the Redirect field in the UI (see image in copy)

tedbow’s picture

Similar issue: it looks like in the case of an "edit" and not a "submit" the Redirect path that you select is overwritten in all cases in entityform_edit_form_submit()...

The redirect help text says:

What relative path should the user be redirected to on a correct submission?

So this is meant to be just for submitting and not editing. I am not sure I want to change that behavior because it change existing behavior for many sites that are using Entityform.

tedbow’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)
rodrigoaguilera’s picture

Version: 7.x-1.1 » 7.x-2.x-dev
Status: Closed (works as designed) » Needs review
StatusFileSize
new0 bytes

As far as I can understand is still not possible to change the redirect from a hook_form_alter.

Here's a hacky but simple approach to achieve it. Maybe is useful to make it a drupal_alter and make it part of the api.

No interdiff since is a new approach.

rodrigoaguilera’s picture

StatusFileSize
new651 bytes

Bad patch

sergei_brill’s picture

Add drupal_alter for redirect is good idea. For example, I display form on landing pages. And I'd like to set different redirect paths for different landing pages.

sergei_brill’s picture

Just tried to use drupal_alter. It works for me.
PS patch was created from another repo, I'm not sure it could be applied automatically. I can provide normal patch if module maintainer aggree this fix

Status: Needs review » Needs work

The last submitted patch, 8: entityform-add_hook_redirect_path_alter-2081343-8.patch, failed testing.

rodrigoaguilera’s picture

Status: Needs work » Needs review
StatusFileSize
new1.92 KB

I like the hook approach better.

Here is the patch that applies with more documentation for the params.

rodrigoaguilera’s picture

Ooops the drupal_alter happened when saving a draft.

Corrected patch

sam0971’s picture

There was a typo in the entityform.api.php file. $redirect should be $redirect_path. I fixed this typo and added the patch.

joelpittet’s picture

If you form_alter's submit handler comes after entityform_edit_form_submit you can do this without introducing a new hook. Have you tried this yet?

capysara’s picture