I have a view with to models: contact and phones, and I want to create a view to update this two models, my view is like this:
<?php $form = ActiveForm::begin(['id'=>'Contact']); ?>
<?= $form->field($model, 'name')->textInput() ?>
<?php Pjax::begin(); ?>
<?= \yii\grid\GridView::widget([
'id' => 'phonesGrid',
'dataProvider' => new ArrayDataProvider([
'allModels' => $fones,
'sort' => [
'attributes' => ['number', 'ramal'],
],
'pagination' => false,
]),
'columns' => [
'number',
'ramal',
['class' => 'yii\grid\ActionColumn']
],
]); ?>
<?php Pjax::end(); ?> <?php ActiveForm::end(); ?>
The problem is when i call $.pjax.reload the action (create ou update) of ContactController is call but the request not has the form data of contact and the data entering is clear.
How can i do this in YII2?
Thanks.
If I understand your question correctly, you get an empty response from the
pjaxcall. This might be caused by the fact that you have your actualform(and it'smodels) are outside of thepjaxcall, causing it NOT to refresh them and making no connection whatsoever.In my opionion it's best to contain ALL the data you have inside a
pjaxwithqueries/models. For instance:When a pjax.reload is called on all-tags, it will also perform a new query and therefore return a new array of data.
Hopefully this is helpful to you.