Hi,

I would like to redirect the user to different landing pages, depending on whether the node form submission succeeds or not.

Since the submit handlers are only called when the form passes validation, I though it would be a good idea to set a redirect path in my custom validation handler and then overwrite that value in my custom submit handler. It however seems impossible to set the redirect path in a validation handler, as it gets overwritten by the Node core module... any ideas?

Thanks
Oskar

Comments

Everett Zufelt’s picture

Status: Active » Fixed

From what I can tell you want to redirect a user to a particular path on successful submission of a node of a particular content-type.

I strongly suggest that you look at the Rules module.

oskarg’s picture

Status: Fixed » Active

Yes, that is the trivial part.

The hard part is to redirect the user to a different page (or actually the same page but a different tab) if the node submission fails, due to invalid input.

Everett Zufelt’s picture

Can you please provide more detail about the use case? Are you looking for binary redirection: path1 for success, path2 for fail. Or, are you looking for more granular control over redirection based on a set of validation criteria?

oskarg’s picture

I'm sorry for not being clear. The use case is as follows:

There is a Project node type, onto which users can place bids (Bid node type). Project node pages display several tabs, of which one tab is called "All bids" (default) and one is called "New bid".

The "New bid" tab holds a form for creating a new bid. If the node creation succeeds I want to redirect the user to [site-url]/project/[proj-nid], i.e. to the project node page, with default tab expanded. However if bid node creation fails, I want the user to be redirected to [site-url]/project/[proj-nid]#bid-node-form, i.e. to the project node page with the "New bid" tab expanded.

So to conclude; binary redirection is (thankfully) sufficient.

Version: 7.9 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.