hi i am creating reset password form in my application i am stuck in this…
my form
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$error = $model->getErrors();
print_r($error);
if(isset($_GET['msg']))
echo '<div>'.$_GET['msg'].'</div>';
?>
<form method="post" action="<?php echo Yii::app()->getBaseUrl(true).'/index.php/admin/user/resetpassword'?>" enctype="multipart/form-data">
<div class="row">
<label>Old Password</label><input type="text" name="oldpassword" value="<?php echo $model->email; ?>"/><span><?php if(isset($error['email'])) echo $error['email'][0]; ?></span>
</div>
<div class="row">
<label>New Password</label><input type="password" name="newpassword"/><span><?php if(isset($error['password'])) echo $error['password'][0]; ?></span>
</div>
<div class="row">
<label>Repeat Password</label><input type="text" name="repeatpassword" value="<?php echo $model->employeeid; ?>"/><span><?php if(isset($error['employeeid'])) echo $error['employeeid'][0]; ?></span>
</div>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Reset Password' : 'Save'); ?>
</form>
print_r($error) is giving me array
Array ( [email] => Array ( [0] => Email cannot be blank. ) [password] => Array ( [0] => Password cannot be blank. ) [employeeid] => Array ( [0] => Employeeid cannot be blank. ) [designation] => Array ( [0] => Designation cannot be blank. ) [manager] => Array ( [0] => Manager cannot be blank. ) [profilepic] => Array ( [0] => Profilepic cannot be blank. ) )
my controllerfunction
public function actionResetPassword()
{
$model = new User;
if(Yii::app()->request->isPostRequest)
{
$model->validate();
$this->redirect(array('resetpassword','msg'=>'Password successfully changed..'));
}
$this->render('resetpassword',array('model'=>$model));
}
my rules array()
return array(
array('email, password, employeeid, designation, manager, profilepic', 'required'),
array('email','email'),
array('profilepic','file','types'=>'jpg,jpeg,png','allowEmpty'=>true,'on'=>'update'),
array('email,employeeid','unique'),
array('password,repeatpassword,oldpassword','required','on'=>'resetpassword'),
array('email, password, employeeid, designation, manager, profilepic', 'safe', 'on'=>'search'),
);
problem is when i am submit form at that time it’s giving error say “email,password,employeeid etc… is required”… it’s not validating oldpassword,newpassword and repeatpassword field at all
i have created three variables inside model class
public $oldpassword;
public $newpassword;
public $repeatpassword;
i don’t to how to receive form values in this variable? and how to perform check validation…
can anybody give me some suggestion
Thanks in advance