a) use http://bin.cakephp.org or other bin of preference to show your code b) Model::save() validation parameter defaults to true, no need to force it c) number of reasons why you don't see messages you may not print it in the view - compare your add and edit views or your validation rules 'on' options set to 'create'
On Mon, Apr 18, 2011 at 1:57 PM, Krissy Masters <[email protected]> wrote: > if ($this->Post->save($this->data)) { you not forcing validation check > > add true > > if ($this->Post->save($this->data, true)) { > > K > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf > Of jackgoh > Sent: Monday, April 18, 2011 3:23 PM > To: CakePHP > Subject: Validation errors only working in Add form, but not in Edit form. > > Hi, > > > The validation message is working in Add Form, but not in the Edit > Form, can anyone help me? > Part of my code in the controller: > > function edit($id = null) { > $this->Post->id = $id; > $sectors = $this->Post->Sector->find('list', array( > > 'fields' => array('id','combined_name'), > > 'conditions' => array('status' => 'A') > > ) > ); > $this->set(compact('sectors')); > > if (empty($this->data)) { > $this->data = $this->Post->read(); > } else { > if ($this->Post->save($this->data)) { > $this->Session->setFlash('Your record has > been updated.'); > $this->redirect(array('action' => 'index')); > } else { > $this->Session- >>setFlash('Error.'); > } > } > } > > Thanks! > > Best regards. > > -- > 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 > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php > > -- > 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 > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php > -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
