dimis283
(Dimis283)
1
I have a user register (not from Yii crud) page and I want the pass to be md5(pass) so I write this code that does not work, what is wrong?
public function onBeforeSave($event) {
$pass = md5($this->usr_pass);
$this->usr_pass= $pass;
// $this->usr_pass=md5( $this->usr_pass);
// $this->password_repeat=md5( $this->password_repeat);
// die( $this->usr_pass);
return true;
}
mikl
(Mike)
2
The method should be called "beforeSafe".
crazyman4068
(Francisco A Ferrari)
3
Try something like this (in the Model):
public function init(){
$this->onBeforeSave=array($this,'crypt');
parent::init();
}
public function crypt($event) {
$model = $event->sender;
$pass = md5($model->usr_pass);
$model->usr_pass= $pass;
$event->isValid=true
return true;
}
mhameen
(M H Ameen13)
4
public function beforeSave() {
$pass = md5($this->usr_pass);
$this->usr_pass= $pass;
// $this->usr_pass=md5( $this->usr_pass);
// $this->password_repeat=md5( $this->password_repeat);
// die( $this->usr_pass);
return true;
}
works with me