Re: Form validation and routes - errors lead to controller/action instead of route!
Hey, ok I found the solution, and it's really simple. Just use the 'url' option for the form, and the routes will be no problem anymore. Here is a brief example how to do it: In Routes-PHP, there is an entry: Router::connect('/register', array('controller' => 'users', 'action' => 'register')); And the form in the view of the register action (views/users/ register.ctp) create the form like this: create('User', array('url' => '/register')); ?> That points the form to the correct route, which will lead to the correct action. On errors like empty input fields the route will be the same again and everthing works fine. Regards, DD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Form validation and routes - errors lead to controller/action instead of route!
Hey, the problem I have came up very often the last weeks but I couldn't find a solution yet. Maybe one of you has a clue how to do this. The facts: in my users_controller i have an action called "register", which is mapped to the route http:://www.domain.com/register This is working, and very easy to set up. But when I now make any mistake in the form given in the register action, the url in the browser switches back to users/register, which is the correct action, but not the correct route! I could do a redirect when an error occurs, but the form validation errors (by model validation OR invalidate()) are gone when a redirect is done. There has to be a solution for this, I just do not want to store all errors in the Session and add the errors manually into the form and delete them afterwards from the Session. Does anyone have any idea how to solve this little problem? Regards, DD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en