Example #1
0
 public function beforeSave($options = array())
 {
     if (!empty($this->data[$this->alias]['password'])) {
         App::uses('AuthComponent', 'Controller/Component');
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
     parent::beforeSave($options);
 }
 /**
  * Called before each save operation, after validation. Return a non-true result
  * to halt the save.
  *
  * @param array $options Options passed from Model::save().
  * @return bool True if the operation should continue, false if it should abort
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave
  * @see Model::save()
  */
 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['key']) && isset($this->data[$this->alias]['code']) && !$this->data[$this->alias]['code']) {
         $this->data[$this->alias]['code'] = $this->data[$this->alias]['key'];
     }
     return parent::beforeSave($options);
 }