php - Yii2 Executes the view twice -


i've changed index action login action , view executes twice enter image description here

why happend ?

can me ?

this layout:

    <?php /* @var $this \yii\web\view */ /* @var $content string */  use yii\helpers\html; use app\assets\loginasset;  loginasset::register($this); ?> <?php $this->beginpage() ?> <!doctype html> <html lang="<?= yii::$app->language ?>">     <head>         <meta charset="<?= yii::$app->charset ?>">         <meta name="viewport" content="width=device-width, initial-scale=1">         <?= html::csrfmetatags() ?>         <title><?= html::encode($this->title) ?></title>         <?php $this->head() ?>     </head>         <body class="fixed-header">         <?php $this->beginbody() ?>          <div class="login-wrapper">             <?= $content ?>         </div>          <?php $this->endbody() ?>     </body> </html> <?php $this->endpage() ?> 

this view:

<?php /* @var $this yii\web\view */ /* @var $form yii\bootstrap\activeform */ /* @var $model app\models\loginform */  use yii\bootstrap\activeform; use yii\helpers\url; use yii\helpers\html;  $this->title = 'tramite al dia - login'; ?>  <div class="bg-pic">     <!-- start background pic      <img src="<?= url::base() ?>/public/pages/assets/img/demo/new-york-city-buildings-sunrise-morning-hd-wallpaper.jpg" height="1200" width="1920" class="lazy">  -->         <!-- end background pic -->     <!-- start background caption-->     <div class="bg-caption pull-bottom sm-pull-bottom text-white p-l-20 m-b-20">         <h2 class="semi-bold text-white">             en la facilidad esta la felicidad de las personas.         </h2>         <p class="small">             te facilitamos el control del día día con el tramite y gestión de sus documentos, <br> tramite al día &copy; 2015         </p>     </div>     <!-- end background caption--> </div>  <div class="login-container bg-white">     <div class="p-l-50 m-l-20 p-r-50 m-r-20 p-t-50 m-t-30 sm-p-l-15 sm-p-r-15 sm-p-t-40">         <!-- <img src="<?= url::base() ?>/public/pages/assets/img/logo.png" alt="logo" width="78" height="22"> -->             <p class="p-t-35">accede tu cuenta</p>         <!-- start login form -->         <?php $form = activeform::begin(); ?>                  <!-- start form control-->         <div class="form-group form-group-default">             <label>usuario</label>             <div class="controls">                 <?= $form->field($model, "usuario")->label(false); ?>                             </div>         </div>         <!-- end form control-->         <!-- start form control-->         <div class="form-group form-group-default">             <label>contraseña</label>             <div class="controls">                 <?= $form->field($model, "clave")->passwordinput()->label(false); ?>             </div>         </div>         <!-- start form control-->         <div class="row">             <div class="col-md-6 no-padding">                                 <?= $form->field($model, "recuerdame")->checkbox()->label(false) ?>                 <label>mantener sesión iniciada</label>                             </div>             <div class="col-md-6 text-right m-t-10">                 <a href="#" class="text-info small">necesita ayuda?</a>             </div>         </div>         <!-- end form control-->         <?= html::submitbutton("entrar", ["class" => "btn btn-primary btn-cons m-t-10"]) ?>                  <?php activeform::end(); ?>         <!--end login form-->     </div> </div> 

and controller

<?php  namespace app\controllers;  use yii; use yii\filters\accesscontrol; use yii\web\controller; use yii\filters\verbfilter; use app\models\loginform;  class sitecontroller extends controller {      public $layout = "login";      public function behaviors() {         return [             'access' => [                 'class' => accesscontrol::classname(),                 'only' => ['logout'],                 'rules' => [                     [                         'actions' => ['logout'],                         'allow' => true,                         'roles' => ['@'],                     ],                 ],             ],             'verbs' => [                 'class' => verbfilter::classname(),                 'actions' => [                     'logout' => ['post'],                 ],             ],         ];     }      public function actions() {         return [             'error' => [                 'class' => 'yii\web\erroraction',             ],             'captcha' => [                 'class' => 'yii\captcha\captchaaction',                 'fixedverifycode' => yii_env_test ? 'testme' : null,             ],         ];     }      public function actionindex() {         $model = new loginform();          if ($model->load(yii::$app->request->post()) && $model->login()):             return $this->redirect(["landing/index"]);         else:             return $this->render('index', [                         'model' => $model,             ]);         endif;     }          public function actionlogout() {         yii::$app->user->logout();          return $this->gohome();     }  } 

first time happend me.

i pretty sure it's rendering in layout files. show code of views/layouts/main.php , if have sub-templates well. e.g. if have there multiple parts of following code result mentioned, e.g. multiple echo of $content.

<?php $this->beginbody() ?> <?= $content ?> <?php $this->endbody() ?> 

another possibility multiple call of echo $this->render('yourview',...) in controller code. should return , not echo render calls e.g. return $this->render('yourview',...) instead. couldn't rendered multiple times.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -