Tuesday, November 30, 2010

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:

<?php echo $form->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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: