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
Comment #1
tedbowI can't think of anything off the top of my head.
I would be interested in the patch.
Thanks
Comment #2
dansanjou commentedSimilar 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)
Comment #3
tedbowThe redirect help text says:
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.
Comment #4
tedbowComment #5
rodrigoaguileraAs 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.
Comment #6
rodrigoaguileraBad patch
Comment #7
sergei_brill commentedAdd 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.
Comment #8
sergei_brill commentedJust 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
Comment #10
rodrigoaguileraI like the hook approach better.
Here is the patch that applies with more documentation for the params.
Comment #11
rodrigoaguileraOoops the drupal_alter happened when saving a draft.
Corrected patch
Comment #12
sam0971 commentedThere was a typo in the entityform.api.php file. $redirect should be $redirect_path. I fixed this typo and added the patch.
Comment #13
joelpittetIf you form_alter's submit handler comes after
entityform_edit_form_submityou can do this without introducing a new hook. Have you tried this yet?Comment #14
capysara commentedCan this be closed as duplicate?
Modifying the url when editing an entityform can be done with a few lines of custom code, see https://www.drupal.org/project/entityform/issues/2397279.
These are all more or less duplicates:
https://www.drupal.org/project/entityform/issues/2512558
https://www.drupal.org/project/entityform/issues/2653098
https://www.drupal.org/project/entityform/issues/2919094
https://www.drupal.org/project/entityform/issues/2081343