Answer the question
In order to leave comments, you need to log in
How to pass back the id of the selected user from the modal window to the view?
I have such a task. In the GridView where you can select multiple applications using the checkbox, you need to make a button, when clicked, a modal window will open and there will be a list of drivers in the GridView, where the "Select" button will be. After selecting a driver, you need to pass his id back to the original view and assign it to requests. I made a modal window with a list of drivers, but I can’t figure out how to pass the id of the selected records there.
I thought to pass parameters through ajax, but then I don’t know how to implement it in a modal window.
Maybe someone can help?
<?php Modal::begin([
'header' => 'Установить водителя',
'size' => 'modal-lg',
'toggleButton' => [
'tag' => 'a',
'class' => 'btn btn-primary',
'label' => 'Установить водителя',
]
]);
echo $this->render('_setDriver');
Modal::end(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'id',
'value' => function ($modal) {
return '#'. $modal->id;
},
],
'name',
'car',
'gov',
'rights',
[
'attribute' => 'id',
'label' => 'Выбрать водителя',
'format' => 'html',
'filter' => false,
'value' => function ($model) {
$value = '<a href="driverChoose?id='.$model->id.'" class="btn btn-danger">Выбрать</a>';
return $value;
}
]
],
]); ?>
Answer the question
In order to leave comments, you need to log in
With js. The modal window is not another page.
You can send a request to the controller with a parameter and reload the page, yes, there are a lot of options, but you didn’t describe enough to go to the specifics
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question