我正在处理具有以下字段的密码重置表单
<==Username==>
<==Current Password==>
<==New Password==>
<==Confirm Password==>
查看代码
<div class="row"><?php
echo $form->labelEx($model,'username');
echo $form->textField($model,'username',array('size'=>45,'maxlength'=>150));
echo $form->error($model,'username'); ?>
</div>
<div class="row"><?php
echo $form->labelEx($model,'Current password');
$model->password="";
echo $form->textField($model,'password',array('size'=>45,'maxlength'=>150));
echo $form->error($model,'password'); ?>
</div>
<div class="row"><?php
echo $form->labelEx($model,'New password');
$model->password="";
echo $form->passwordField($model,'password',array('size'=>45,'maxlength'=>150));
echo $form->error($model,'password'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'password_repeat'); ?>
<?php echo $form->passwordField($model,'password_repeat',array('size'=>45,'maxlength'=>150)); ?>
<?php echo $form->error($model,'password_repeat'); ?>
</div>
<div class="row buttons"><?php
echo CHtml::submitButton('Reset Your Password');
?></div><?php
控制器代码
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// set the parameters for the bizRule
$params = array('GroupzSupport'=>$model);
// now check the bizrule for this user
if (!Yii::app()->user->checkAccess('updateSelf', $params) &&
!Yii::app()->user->checkAccess('admin'))
{
throw new CHttpException(403, 'You are not authorized to perform this action');
}
else
{
if(isset($_POST['GroupzSupport']))
{
$model->attributes=$_POST['GroupzSupport'];
$model->password = $model->hashPassword($_POST['GroupzSupport']['password']);
if($model->save())
$this->redirect(array('admin','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
}
我有以下密码字段需要更新到数据库中。我需要为新密码字段使用密码变量。现在,我需要将当前密码覆盖为新密码并保存。我怎样才能做到这一点。