【问题标题】:Blank page on update after including if condition yii2包含 if 条件 yii2 后更新的空白页
【发布时间】:2017-09-09 12:04:00
【问题描述】:

当我在更新表单中包含 if 条件 时,我得到了空白页。 否则没有 if condition 更新工作正常。

_form.php 没有 if 条件(这工作正常)

    <?= $form->field($model, 'certified')->radioList(['y'=>'YES', 'n'=>'NO'])  ?>

     <div class="row">  
      <div class="row">            
        <?= $form->field($modelcertificate, 'description')->dropDownList(
                    ArrayHelper::map(CertificateDescription::find()->all(),'description','description'),
                    [   'prompt'=>'select desc', 
                    ]); ?>    
      </div>

       <div class="row">

     <?= $form->field($modelqm, 'q1')->textInput(['maxlength' => true]) ?>

      </div>
  </div>

同样,如果我包含 If 条件,点击更新按钮后将显示空白页面。

_form.php 与 if 条件(导致空白页)

 <?= $form->field($model, 'certified')->radioList(['y'=>'YES', 'n'=>'NO'])  ?>

     <div class="row">  
      <?php if ($model->certified == 'y') : ?>  
        <div class="row">              
           <?= $form->field($modelcertificate, 'description')->dropDownList(
               ArrayHelper::map(CertificateDescription::find()->all(),'description','description'),
                                    ['prompt'=>'select desc', ]); ?>       
         </div>
      <?php else: ?>
         <div class="row">
        <?= $form->field($modelqm, 'q1')->textInput(['maxlength' => true]) ?>
    </div>
 <?php endif; ?>
      </div>

【问题讨论】:

  • 在日志文件中检查原因。
  • 它说 [yii\web\HttpException:404] yii\web\NotFoundHttpException: 请求的页面不存在。
  • 但是如果条件不存在,它怎么能正常工作呢?\
  • 不,不是这个错误。
  • 另外,尽量简化if 条件。将其替换为if(true):。如果这可行,您可能会确定 - 问题出在 certified 字段中。

标签: yii2 yii2-advanced-app


【解决方案1】:

问题出在Controller中,所以空白页是缺少返回点造成的。

出于调试目的,可以使用gii生成的CRUD,并逐行改进以满足您的个人需求。

【讨论】:

    猜你喜欢
    • 2011-08-11
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多