Reputation: 61
i am working on the yii framework and just making the different layouts for the different pages. I have created a "login layout" for the login page so that i can design that page as per my requirements. I have just added a few lines of code on the layout file i.e login.php and code is here :
<?php
/* @var $this Controller */
$this->beginContent('//layouts/login');
echo $content;
$this->endContent();
?>
Now, i am using this layout on the UsersController's Login action. But as i set the layout of the action. Yii throws an error of such type which i have given below:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40961 bytes) in /home/teamreal/public_html/yii/framework/web/widgets/COutputProcessor.php on line 33
I have no idea why this error is being displayed again and again where as i have code the action function correcty which is as such:
public function actionLogin() {
$this->layout = 'login';
$model = new LoginForm('login');
// 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);
}
// display the login form
$this->render('login', array('model' => $model));
}
So, please help me out to solve this problem.
Upvotes: 1
Views: 2949
Reputation: 4708
You are decorating the layout/login
over and over again with layout/login
. http://www.yiiframework.com/doc/api/1.1/CBaseController#beginContent-detail
Don't you want the main layout in views/layouts/login
:
<?php
/* @var $this Controller */
$this->beginContent('//layouts/main');
echo $content;
$this->endContent();
?>
Upvotes: 1