add 'required' =>true http://book.cakephp.org/2.0/en/models/data-validation.html#required
On Monday, May 28, 2012 7:23:35 PM UTC+2, John wrote: > > Same on 2.1.3 > > I can "fix" it by checking for an empty array on model or controller but I > I guess this is not expected behavior, should I add a ticket on it? > > On Sunday, May 27, 2012 6:45:08 PM UTC+3, John wrote: >> >> 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php