0

Имеется форма, находящаяся в index-вьюхе:

<?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();?>

Вот так она сразу рендерится: введите сюда описание изображения

Вопрос в том, что у меня после нажатия на кнопку отправки формы форма очищается (к этому и стремлюсь), но после обновления страницы данные возвращаются в текстовые поля. Будто они где-то записались и постоянно считываются обратно.

1 ответ 1

1
...
if ($model->load(Yii::$app->request->post()) && $model->save()) {
    $isSave = true;
    $model = new Order();
}
...
2
  • пробовал так, без изменений всё остается: жму на кнопку - форма очищается - обновляюсь - форма заполнена предыдущими данными.
    – anhckie
    12 мая 2016 в 11:31
  • Alexandr написал верно, проверьте повторно ваш код
    – NPreston
    13 мая 2016 в 10:34

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.