Hello friends
I´m trying using the password validantion and I had a error, I´m using this sample:
http://www.yiiframework.com/wiki/277/model-password-confirmation-field
I received this error:
Property "User.repeat_password" is not defined.
Why this error?
This is my model:
public function rules()
{
return array(
array('password, repeat_password', 'required', 'on'=>'insert'),
array('email,user,name', 'required'),
array('email', 'email'),
array('passeord,repeat_password', 'length', 'max'=>250),
array('user, name', 'length', 'max'=>50),
array('email', 'length', 'max'=>250),
array('password', 'compare', 'compareAttribute'=>'repeat_password'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('password, user, name, email', 'safe', 'on'=>'search'),
);
}
This is my form:
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'repeat_password'); ?>
<?php echo $form->passwordField($model,'repeat_password'); ?>
<?php echo $form->error($model,'repeat_password'); ?>
</div>
This is my controller:
public function actionInsert(){
$model = new Users;
if(isset($_POST['Users'])){
$model->attributes=$_POST['Users'];
$model->senha = $this->getHashPassword($_POST['Users']['password']);
if($model->save()){ $this->redirect(array('index')); }
}
$this->render('create', array('model'=>$model));
}