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

Reply via email to