我想在特殊页面更改密码。在yii应用程序中更改密码页的问题
当我点击“更改密码”,我必须去密码视图。
这是从那里我需要去
<?php
/* @var $this UserController */
/* @var $model User */
$this->menu=array(
array('label'=>'User List', 'url'=>array('index')),
array('label'=>'Create User', 'url'=>array('create')),
array('label'=>'View User', 'url'=>array('view', 'id'=>$model->id)),
array('label'=>'Change password', 'url'=>array('password', 'id'=>$model->id)),
);
?>
<h1>Change user <?php echo $model->id; ?></h1>
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
用于更新视图代码这是我password.php查看文件
<?php
$this->menu=array(
array('label'=>'List user', 'url'=>array('index')),
array('label'=>'Create user', 'url'=>array('create')),
array('label'=>'View user', 'url'=>array('view', 'id'=>$model->id)),
array('label'=>'Change user', 'url'=>array('update', 'id'=>$model->id)),
);
?>
<?php
CHtml::beginForm();
CHtml::textField('password');
CHtml::submitButton('Change');
CHtml::endForm();
?>
UserController中有动作actionPassword()
public function actionPassword($id) {
$model=$this->loadModel($id);
$model->password=$_POST['password'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
$this->render('password');
}
在例子中,我使用这段代码工作正常。但我有错误 http://pastebin.com/XbCwfhRT
所有文件和文件夹都具有root权限。我做错了什么?一个月前相同的代码工作正常,我不明白什么知道出错。
'$ model'被正确创建了吗? '$ id'中的值是否有效?如何'var_dump($模型);'确保。将密码保存为明文也是个不错的主意。 – Pitchinnate
我在没有它的情况下加入密码功能。 ID有效。我有正确的$模型和$ ID。在URL中我有正确的链接。但页面不起作用。 –