Why don't you do the validation on the same page using javascript if
you're going that route. Otherwise, you will have to use the model
validation and let the controller method complete what it needs to.
if($this->Model->create($this->data) && $this->Model->validates()) {
     if($this->Model->save($this->data)) {
           $this->redirect('/somewhere');
           exit;
     } else {
          throw new Exception("Could not save the user data!");
     }
} else {
     $this->render();
     exit;
}

On Nov 30, 3:45 pm, peterhf <[EMAIL PROTECTED]> wrote:
> How does one execute a JS script before the html request is made and
> halt the request based on some condition in the JS? For instance, I
> wish to check that required fields are correctly populated; if any
> required field is not correctly populated, I want to show an alert and
> return to the page without completing the http request. I am using the
> 'before' option in the submit but have not discovered how to stop the
> request from completing.
>
> Thanks in advance for your suggestions.
>
> Peter -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to