Friday, February 25, 2011

CakePHP form validation before sending post to the requested controller function

My validation is working as it stands, but I want to display the validation error prior to the search controller. I understand this might not be possible within the CakePHP framework.

I have a model plan.php. And in the plans_controller.php, I have a function called search().

My form calls search() as expected (because there is no search model):

echo $this->Form->create('Plan', array('action' => 'search'));

As it stands, when I submit my search, the errors are displayed and the url changes to .../search, so no results are displayed ("There are 0 results for that search criteria", but the correct validation errors are displayed below required form fields.

I do not want the .../search url to be displayed. I want the form to "halt" and just display the validation errors w/out changing the url to the search function.

I am calling the search form within an element because the search form displays on several different pages.

To sum this up: The search form should validate w/out changing the url path to the controller action name of the search. Of course, the validation is done IN the search() and plan.php model, so I just don't know how to work around this and wondering if its even possible.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: