cake-php@googlegroups.com
[Top] [All Lists]

Re: Validation errors only working in Add form, but not in Edit form.

Subject: Re: Validation errors only working in Add form, but not in Edit form.
From: stas kim
Date: Mon, 18 Apr 2011 16:36:06 -0400
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
<naked.cake.baker@xxxxxxxxx> 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: cake-php@xxxxxxxxxxxxxxxx [mailto:cake-php@xxxxxxxxxxxxxxxx] 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
> cake-php+unsubscribe@xxxxxxxxxxxxxxxx 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
> cake-php+unsubscribe@xxxxxxxxxxxxxxxx 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
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at 
http://groups.google.com/group/cake-php

<Prev in Thread] Current Thread [Next in Thread>