0

When I include if condition in update form I'm getting blank page. Otherwise without if condition update works fine.

_form.php without if condition (this works fine)

    <?= $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>

For the same if I include If condition, after hitting update button blank page will be shown.

_form.php with if condition ( leads to blank page)

 <?= $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>
Rachna
  • 39
  • 13
  • Check for reason in log file. – Yupik Apr 13 '17 at 11:30
  • It says **[yii\web\HttpException:404] yii\web\NotFoundHttpException: The requested page does not exist.** – Rachna Apr 13 '17 at 11:39
  • But how come it works fine when if condition is not there??\ – Rachna Apr 13 '17 at 11:40
  • No, it's not this error. – Yupik Apr 13 '17 at 11:41
  • It;s not logged, I don't find any – Rachna Apr 13 '17 at 12:03
  • Update your if condition without space like this certified == 'y'): ?> – Irfan Ali Apr 13 '17 at 12:24
  • The if condition evaluates to false, since at the moment of rendering the file the `certified` field does not have a value. The problem might be in the controller. – gmc Apr 13 '17 at 15:42
  • Look at web server error.log. If you use Apache, [they might be here](https://unix.stackexchange.com/a/39008) – wormi4ok Apr 13 '17 at 16:26
  • 1
    Also, try to simplify you `if` condition. Replace it with `if(true):`. and if this works, you might be sure - problem is in `certified` field. – wormi4ok Apr 13 '17 at 16:31
  • @Irfan Ali, No change after removing the space – Rachna Apr 14 '17 at 05:05
  • @gmc, I'm facing this problem during update and in create action I have made it to mandatory to select one option, so there is no way the certified field being null or empty. (Create and update have different forms and in create form there is no if condition, I have included only in the update form) – Rachna Apr 14 '17 at 05:11
  • @wormi4ok, I'am using NGINX – Rachna Apr 14 '17 at 05:15
  • @wormi4ok If I replace it with` if(true):` and remove the `else` condition it is working but with `else` condition it will lead to blank page – Rachna Apr 14 '17 at 05:22
  • In case you use Nginx, examine its error.log. Location [should be specified](http://stackoverflow.com/questions/1706111/where-can-i-find-the-error-logs-of-nginx-using-fastcgi-and-django) in you server configuration – wormi4ok Apr 14 '17 at 07:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/141700/discussion-between-rachna-and-wormi4ok). – Rachna Apr 14 '17 at 08:00
  • Checked it, I don't find anything related to update can placing of
    and if statement lead to this type of behavior??
    – Rachna Apr 14 '17 at 08:05

1 Answers1

1

The problem was in Controller, so blank page is caused by missing return point.

For debug purposes it possible to use CRUD generated by gii, and improve it line by line to fit your personal needs.

wormi4ok
  • 602
  • 7
  • 11