In normal scenario user enters details into form fields and submits data. On submission model validates the data and if validation fails user is redirected to same page with error notifications.
I have a particular scenario in which if the validation fails user should be redirected to a specified page. I DONT want the user be redirected to the same page from where he posted the data.
I went through the cake documentation. But couldnt find anything that mentions a redirect on data validation failure. It can be achieved if im using validating from controller. But here im validating using rules in model only.
Will it be possible?
By default, if data validation fails, the user is not ‘redirected’ anywhere. Cake displays the same view, without any redirecting. The view always shows validation errors, if they exist. So, of course the first time you load the form, there are no errors, but after submitting incorrect data, there are errors. But it’s the exact same view both times, and no redirection is used.
To fix your problem, modifying the example here: http://book.cakephp.org/2.0/en/models/saving-your-data.html you should be able to do something like:
Is there any reason that won’t work for you?