/** * 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 = array('comment' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'If it is not approved, comment is a required input.'), 'required' => true))); return parent::beforeValidate($options); }
/** * Overrides AppModel::delete() method * * Automatically decrement comment count of related model * * (non-PHPdoc) * @see cake/libs/model/Model#delete($id, $cascade) */ public function delete($id = null, $cascade = true) { $success = false; if (is_null($id)) { $id = $this->id; } if ($this->changeCount($id, 'down')) { if (parent::delete($id, $cascade)) { $success = true; } else { $this->changeCount($id, 'up'); } } return $success; }
/** * @copydoc AppModel::__construct() */ public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this->validate = array('email' => array('notEmpty' => array('rule' => 'notEmpty', 'message' => __('Please enter your email address')), 'email' => array('rule' => array('email'), 'message' => __('Please enter a valid email address'))), 'comment' => array('notEmpty' => array('rule' => 'notEmpty', 'message' => __('Please enter your comments')))); }