Answer the question
In order to leave comments, you need to log in
How did pjax reset the form when submitting the form?
pjax is used Inside pjax, a form is sent and a flash message is displayed. It turns out that when the form is sent, the input is not reset and exits when the page is refreshed again, a new line is added to the database. In the controller I wrote
if($reminder->load(Yii::$app->request->post())){
$reminder->getReminder($zakaz);
if($reminder->validate() && $reminder->save()){
Yii::$app->session->setFlash('success', 'Напоминание было созана');
} else {
Yii::$app->session->setFlash('error', 'Извините. Напоминание не было создана');
}
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
<?php $formReminder = ActiveForm::begin(); ?>
<?= $formReminder->field($reminder, 'srok')->textInput(['type' => 'datetime-local', 'required' => 'required']) ?>
<?= Html::submitButton('Напомнить', ['class' => 'btn btn-primary btn-sm']) ?>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Why is pjax in pjax? And what's with the code you gave? He has nothing to do with it. And how do you plan to combine pjax and $this->redirect? Pjax makes a request and needs to get $this->render to do its job and replace the content. And you do not give him content.
Clear the data from the class stored in the $reminder variable after saving
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question