Ejemplo n.º 1
0
 /**
  * Additional form processing before validation
  * @return bool
  */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         // remove non-numeric from phone number
         if (isset($this->attributes['WorkPhone'])) {
             $this->setAttribute('WorkPhone', preg_replace('/[^0-9]/', '', $this->attributes['WorkPhone']));
         }
         return true;
     }
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 protected function beforeSave()
 {
     // hash password on create
     if (($this->scenario == 'create' || $this->scenario == 'edit') && !empty($this->UserPassword)) {
         $this->UserPassword = md5($this->UserPassword);
     }
     // don't clear password if not set
     if (empty($this->UserPassword)) {
         unset($this->UserPassword);
     }
     return parent::beforeSave();
 }