/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('title' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('bbses', 'Title')), 'required' => true)), 'content' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('bbses', 'Content')), 'required' => true)))); if (!parent::beforeValidate($options)) { return false; } if (isset($this->data['BbsArticleTree'])) { $this->BbsArticleTree->set($this->data['BbsArticleTree']); if (!$this->BbsArticleTree->validates()) { $this->validationErrors = Hash::merge($this->validationErrors, $this->BbsArticleTree->validationErrors); return false; } } return true; }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('bbses', 'Bbs name')), 'required' => true)))); if (!parent::beforeValidate($options)) { return false; } if (isset($this->data['BbsSetting'])) { $this->BbsSetting->set($this->data['BbsSetting']); if (!$this->BbsSetting->validates()) { $this->validationErrors = Hash::merge($this->validationErrors, $this->BbsSetting->validationErrors); return false; } } if (isset($this->data['BbsFrameSetting']) && !$this->data['BbsFrameSetting']['id']) { $this->BbsFrameSetting->set($this->data['BbsFrameSetting']); if (!$this->BbsFrameSetting->validates()) { $this->validationErrors = Hash::merge($this->validationErrors, $this->BbsFrameSetting->validationErrors); return false; } } }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('bbs_article_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'required' => true)), 'user_id' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'required' => true)))); return parent::beforeValidate($options); }