Sunday, May 27, 2012

Empty array on Model::save bypasses validation

On 2.1 if I do $this->Category->save($this->request->data) and $this-
>request->data is an empty array() model validation is bypassed and an
"empty" record is saved.

My model validation as baked:

class Category extends AppModel {
public $displayField = 'name';
public $validate = array(
'name' => array(
'notempty' => array(
'rule' => array('notempty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update'
operations
),
),
);
}

--
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@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: