南龙 2012-08-22 17:23:46 3844次浏览 0条回复 0 0 0

这个是控制层的

<?php
public function actionIndex()
	{
		// renders the view file 'protected/views/site/index.php'
		// using the default layout 'protected/views/layouts/main.php'
        $model=new LoginForm;
        $regModel=new RegForm;
		$this->render('index', array('model' => $model,'regModel' => $regModel));
	}

/**
	 * Displays the login page
	 */
	public function actionLogin()
	{
		$model=new LoginForm;

		// if it is ajax validation request
		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())
            {
				$this->redirect(Yii::app()->user->returnUrl);
            } else {
                var_dump($model);
                //$this->redirect(array('/site/index'));
            }
		}
		// display the login form
		//$this->render('login',array('model'=>$model));
	}
?>

http://127.0.0.1/index.php?r=site/index 页面显示 点击登录以后执行site/login方法.出错返回到site/index页面,但是页面不会显示出错信息,要怎么才能把这个错误信息带上?

<?php
//登录表单开始
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
    'id' => 'LoginForm',
    'htmlOptions' => array('class' => 'well'),
    'action' => array('/site/login'),
    'method' => 'post',
));
echo $form->textFieldRow($model, 'username', array('class' => 'span3'));
echo $form->passwordFieldRow($model, 'password', array('class' => 'span3') );
echo $form->textFieldRow($model, 'verifyCode',array('class' => 'span3'));
$this->widget('CCaptcha', array(
    'buttonLabel' => '看不清楚,换一张',
    'imageOptions' => array(
        'id' => 'LoginCode',
    )

));
echo $form->checkboxRow($model, 'rememberMe');
$this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'icon'=>'ok', 'label'=>'登录'));
$this->endwidget();
?>
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册