简体   繁体   中英

cakephp how to handle errors on saveField

Guys i am wondering if there is a way to error handle saveField() in cakePhp. I tried to produce an error manually by setting for example a fake column

$saveCss = $this->Menu->saveField('fakeColumn','test');

But i get the same result as an existing column. Any ideas how to handle them?

Have you got a beforeValidate() or beforeSave() method in the model or app model? Ifso, are they returning true? Failing that, use a debugger.

This will probably give you the info you need

 if(!$this->Menu->saveField()){
        debug($this->validationErrors); die();
    }

You can use Cake Guide as reference http://book.cakephp.org/2.0/en/models/saving-your-data.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM