There is a form located in the index view:

<?php Pjax::begin(['id' => 'formPjax']);$form = ActiveForm::begin(['id' => 'contactForm', 'options' => ['data-pjax' => true]]); ?> <?= $form->field($model, 'name')->textInput(['autofocus' => false, 'placeholder' => 'Name', 'class' => 'form-control', 'required' => true]) ?> <?= $form->field($model, 'email')->textInput(['autofocus' => false, 'placeholder' => 'Email', 'class' => 'form-control', 'required' => true, 'type' => 'email', 'id' => 'email']) ?> <?= $form->field($model, 'phone')->textInput(['autofocus' => false, 'placeholder' => 'Phone', 'class' => 'form-control', 'required' => true]) ?> <?= $form->field($model, 'message')->textArea(['autofocus' => false, 'placeholder' => 'Message', 'class' => 'form-control', 'required' => true, 'rows' => 5]) ?> <?= Html::submitButton('Send', ['class' => 'btn btn-success btn-lg']); if($isSave === true) echo "<b style='float:none' class='navbar-brand'>Ваше сообщение было доставлено</b>"; $model = new Order();?> 

This is how it is rendered immediately: enter image description here

The question is that after I click on the submit button, the form is cleared (I want to do this ), but after updating the page, the data is returned to the text fields. As if they were somewhere enrolled and constantly read back.

    1 answer 1

     ... if ($model->load(Yii::$app->request->post()) && $model->save()) { $isSave = true; $model = new Order(); } ... 
    • I tried it, everything remains unchanged: I press the button - the form is cleared - updated - the form is filled with the previous data. - Anque
    • Alexandr wrote correctly, check your code again - NPreston