3

I've read and experimented with several ways to redirect a form once submitted. However, I only want to redirect a node form if the operation is t('Save').

If I set $form['#redirect'] = 'blah' in form_alter, it will redirect on all types of form submits. If I add a submit handler and then set $form_state['redirect'], this just gets overridden by drupal's node_form_submit.

What is the correct way to redirect a node submit only if the submit operation was say t('Save')?

NOTE: I found out that the generic form_alter attempt of $form['#redirect'] interferes with the node delete submit handler, as it has to redirect to node/%node/delete. So hence I am looking for a more accurate method.

4

The answer was to attach my submit handler to the submit button rather than the form, and then the $form_state['redirect'] would work as needed.

  • @zerolab you are correct, yet I am only allowed to do this after a certain time period ;) – lordg Mar 9 '11 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.