Form validates itself right after on page load

Hi!

I use ActiveForm widget to generate a form and everything works fine except when I visit the page with the form, the form validates itself right after the page is loaded - all required fields are red and if I enable error summary it shows up as well. What could possibly trigger it?

I simplified the code to bare minimum:


<?php

use yii\helpers\Html;

use yii\widgets\ActiveForm;

?>


<div class="order-form">

    <?php $form = ActiveForm::begin(); ?>


    <?= $form->field($customer, 'firstname')->textInput() ?>

    <?= $form->field($customer, 'surname')->textInput() ?>

    <?= $form->field($customer, 'email')->textInput() ?>

    <?= $form->field($customer, 'telephone')->textInput() ?>


    <?php ActiveForm::end(); ?>

</div>

I think the error is produced by the controller.

Just my guest, you didn’t check if there is a posted form in the action, and the controller validate the model no matter you first enter the page or actually posting the form.

Can you post the action function in Controller?