mercredi 24 mai 2017

Update action is not working when "if condition" is introduced in active form YII2

Below is the _form.php (only if condition)

    <?php if($model->certified =='n') :  ?>

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

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

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

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

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

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

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

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

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

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

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

    <?= $form->field($modelqm, 'q15')->textInput(['maxlength' => true]) ?>
     <?php else: ?> 
    <?= $form->field($modelqm, 'q16')->textInput() ?>




  <?= $form->field($modelcertificate, 'description')->dropDownList(
                                         ArrayHelper::map(CertificateDescription::find()->all(),'description','description'),
                                        [   'prompt'=>'select desc', 

                                        ]); ?>  




    <?= $form->field($modelcertificate, 'types')->dropDownList(
                                         ArrayHelper::map(CertificateType::find()->all(),'type','type'),
                                        [   'prompt'=>'select type', 

                                        ]); ?>    


    <?= $form->field($modelcertificate, 'file')->fileInput() ?>
    <?= $form->field($modelcertificate, 'validity')->textInput() ?>
   <?php endif; ?>

The above code works fine(once tables are updated, navigates to view). But when I change the position of the else statement, that is placing else after ** field($modelqm, 'q16')->textInput() ?>** (after immediate next line) Update doesn't happen. it just reloads the update form(page) with new values entered but these values won't be saved into database tables.

**I have checked the div tag I don't have any unclosed tags. interchanged contents in if and else condition but it doesn't resolve the issue.

What could be the reason for this kind of behavior? Has anyone faced this kind of issue?? How do I solve this

Aucun commentaire:

Enregistrer un commentaire