How to make submit forms and auto-update a ListView?

Hello. Understand that theme is pretty worn out, but after a day of trial did not work out. The bottom line is this: there is a widget in this form to add a comment and a sheet view
<?
$form = ActiveForm::begin(['id' =--> 'form-feedback',
 'enableAjaxValidation' => true,
 'action' => '/feedback/index'
]);?>
?>

<?= $form--->field($model, 'name')->textInput(['value' => !Yii::$app->user->isGuest ? Yii::$app->user->identity->username : "]) ?>

<?= $form--->field($model, 'email')->textInput(['type' => 'email', 'value' => !Yii::$app->user->isGuest ? Yii::$app->user->identity->email : "])?>

<?= $form--->field($model, 'comments')->textarea(['rows' => 5]) ?>

<?= $form--->field($model, 'id_obj')->textInput(['type' => 'hidden', 'value' => $id_obj])->label(false)?>

<?= $form--->field($model, 'type')->textInput(['type' => 'hidden', 'value' => $type])->label(false)?>

<div class="form-group">
 <?= Html::submitButton('<span-->Send', ['class' => 'btn btn-primary reg-btn', 'name' => 'signup-button']) ?>
</div>

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


<?= ListView::widget([
 'dataProvider' =--> $dataProvider,
 'itemView' => '_list',
 'layout' => "{summary}\n{items}\n{pager}",
 'summary' => ",
 'itemOptions' => [
 'tag' => 'div',
 'class' => 'feedback',
],
]);
?>


a controller that processes data
public function actionIndex(){

 $model = new Feedback;

 if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
 Yii::$app->response->format = Response::FORMAT_JSON;
 return ActiveForm::validate($model);
}

 if ($model->load(Yii::$app->request->post()) && $model->save()) {
 return Yii::$app->getResponse()->redirect(['/']);

}
 }


The problem is that you need when on the form to do validation, save data and immediately update the sheet view without rebooting.
Many different ways were tried, but get errors in the console, one error pjax Aborted.
Thank you in advance for your help.
July 12th 19 at 17:00
1 answer
July 12th 19 at 17:02
<?php
Pjax::begin(['id'=-->'pjax-container-form']);
$form = ActiveForm::begin(['id' => 'form-feedback',
 'enableAjaxValidation' => true,
 'action' => '/feedback/index',
 'options' => ['data-pjax' => true]
]);?>

<?= $form--->field($model, 'name')->textInput(['value' => !Yii::$app->user->isGuest ? Yii::$app->user->identity->username : "]) ?>

<?= $form--->field($model, 'email')->textInput(['type' => 'email', 'value' => !Yii::$app->user->isGuest ? Yii::$app->user->identity->email : "])?>

<?= $form--->field($model, 'comments')->textarea(['rows' => 5]) ?>

<?= $form--->field($model, 'id_obj')->textInput(['type' => 'hidden', 'value' => $id_obj])->label(false)?>

<?= $form--->field($model, 'type')->textInput(['type' => 'hidden', 'value' => $type])->label(false)?>

<div class="form-group">
 <?= Html::submitButton('<span-->Send', ['class' => 'btn btn-primary reg-btn', 'name' => 'signup-button']) ?>
</div>

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


<?Pjax::begin(['id'=-->'pjax-container-comments']);?>
<?= ListView::widget([
 'dataProvider' =--> $dataProvider,
 'itemView' => '_list',
 'layout' => "{summary}\n{items}\n{pager}",
 'summary' => ",
 'itemOptions' => [
 'tag' => 'div',
 'class' => 'feedback',
],
]);
?>

<? Pjax::end();?>
<?php
$this--->registerJs('
 $("#pjax-container-form").on("pjax:end", function() {
 var url = "' . Url::toRoute(['/feedback/index']) . '";
 $.pjax({url: url, container: "#pjax-container-comments"});
})');
?>

Find more questions by tags Yii