Working with Yii 2 ActiveForm
, I am trying to add a GridView
with search for selecting items to add to a relationship (the database is MongoDB)
I want to include a "Search and Select" GridView
widget, and have the items added to the ActiveForm
model as an array of ids.
For Example:
<?php $form = ActiveForm::begin();?>
<?=$form->field($model, 'summary')->textInput()?>
<?=
GridView::widget([
'id' => 'productSearch',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pjax' => true,
'columns' => [
'name',
],
])
?>
<!-- Display the Assigned Products selected by productSearch -->
<?=
GridView::widget([
'id' => 'assignedProducts',
'dataProvider' => $model->AssignedProducts,
'columns' => ([
'name',
]),
]);?>
<?php ActiveForm::end();?>
However when I include the GridView
search within the ActiveForm::begin()
/ ActiveForm::end()
tags, the "POST" that gets called triggers the form.
Are there any guides on doing this sort of setup?
Or do I need to create the entire form from scratch?
I know I will most likely have to use a bit of jQuery to pull the 'Selected' items from the GridView
when they are selected correct?