I have written two custom function loadError and loadData to load validation errors and form data, respectively.
The trick I use is to set name and id of a form field to data [ModelName][fieldName] ..loadError and loadData than automatically populate validation error and form data.. checkout more about this here http://tinyurl.com/4rrle2 see towards the end of step 5 how two functions are being called...and the required javascript function file is located in app/webroot/js/ FormUtil.js regards, On Dec 13, 8:04 am, Adam Royle <[email protected]> wrote: > Hi Paul, > > You can also access the validation errors directly in the view, so you > could just have this in your controller... > > $this->User->save($this->data); > > and something like this in your view... > > <?php > > $response = array( > 'success' => empty($this->validationErrors), > 'errors' => $this->validationErrors > > } > > echo $javascript->object($response); > > ?> > > Cheers, > Adam > > On Dec 13, 6:50 pm, pkclarke <[email protected]> wrote: > > > Hi Guys, > > > It's OK, I found the "invalidFields()" function. Here's the > > implementation if your interested: > > > if ($this->User->save($this->data)) { > > $this->set('success', '{success:true}');} else { > > > $errors = $this->User->invalidFields(); > > $this->set('success', '{success:false, errors:'.json_encode > > ($errors).'}'); > > > } > > > Cheers Paul. > > > On Dec 13, 7:20 pm, pkclarke <[email protected]> wrote: > > > > I am trying to integrate CakePHP with ExtJS. What is the best way to > > > handle validation? How can I capture validation messages in the > > > Controller so that I can return them to the ExtJS form in JSON format? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
