php yii表单提交后未清除

php yii表单提交后未清除,php,forms,yii,Php,Forms,Yii,我在UserController.php中使用以下代码注册新用户 $model=new Users; if(isset($_POST['Users'])) { $model->attributes = $_POST['Users']; if ($model->register()) { $model->setIsNewRecord(true); if ($mo

我在UserController.php中使用以下代码注册新用户

$model=new Users;

    if(isset($_POST['Users'])) {
        $model->attributes = $_POST['Users'];
        if ($model->register()) {               
            $model->setIsNewRecord(true);
            if ($model->save()) {
                Yii::app()->user->setFlash('info','User registered successfully!!! Please login to Continue.'); 
            } else {
                Yii::app()->user->setFlash('info','Sorry, an unexpected error has occurred!');
            }
        }   
    }
    $this->render('register',array('model'=>$model));
成功注册后,注册表表单保留输入的值。我怎样才能清除这张表格

以下是视图文件-Register.php中的表单代码

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'register-form',
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
    ),
)); ?>    
    <p class="note">Fields with <span class="required">*</span> are required.</p>           
    <div class="row">
        <?php echo $form->labelEx($model,'username'); ?>
        <?php echo $form->textField($model,'username'); ?>
        <?php echo $form->error($model,'username'); ?>
    </div>

-----other textfields in div similar to the above one is present here - not show due to space limit-----

<div id="info"> <font color="red"> <?php foreach(Yii::app()->user->getFlashes() as $key => $message) {
    echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
} ?></font></div>
<div class="row buttons">
    <?php echo CHtml::submitButton('Register'); ?>
</div>

可以清除模型属性,如下所示:

$model->unsetAttributes();
最好将用户重定向到某个页面,甚至是当前页面。或者干脆取消设置$u POST值

例如,如果您不想重定向

unset($_POST['Users']);
或者更好:

$this->redirect('controller/action');
//or Yii::app()->request->redirect('controller/action');
Yii::app()->end();

可以清除模型属性,如下所示:

$model->unsetAttributes();
最好将用户重定向到某个页面,甚至是当前页面。或者干脆取消设置$u POST值

例如,如果您不想重定向

unset($_POST['Users']);
或者更好:

$this->redirect('controller/action');
//or Yii::app()->request->redirect('controller/action');
Yii::app()->end();

显示注册表视图文件添加了视图文件如何添加注册表视图文件添加了视图文件