/** * 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')), 'block_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'on' => 'update')), 'name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('faqs', 'FAQ')), 'allowEmpty' => false, 'required' => true)), 'is_auto_translated' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))))); if (!parent::beforeValidate($options)) { return false; } if (isset($this->data['FaqSetting'])) { $this->FaqSetting->set($this->data['FaqSetting']); if (!$this->FaqSetting->validates()) { $this->validationErrors = Hash::merge($this->validationErrors, $this->FaqSetting->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('faq_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'question' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('faqs', 'Question')), 'allowEmpty' => false, 'required' => true)), 'answer' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('faqs', 'Answer')), 'allowEmpty' => false, 'required' => true)))); if (!parent::beforeValidate($options)) { return false; } if (isset($this->data['FaqQuestionOrder'])) { $this->FaqQuestionOrder->set($this->data['FaqQuestionOrder']); if (!$this->FaqQuestionOrder->validates()) { $this->validationErrors = Hash::merge($this->validationErrors, $this->FaqQuestionOrder->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('faq_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'faq_question_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'weight' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)))); return parent::beforeValidate($options); }