O
O
Oversec2016-09-17 23:06:50
Yii
Oversec, 2016-09-17 23:06:50

Problems in Yii2 GridView?

I need that in the profile of applications (cargo transportation) you can in the driver field, click on the button and a modal window opens with a list of the driver, where you could select the driver.
I just made a modal window in which the page with the GridView is rendered and there is already a list of the driver, but I don’t understand how to assign this driver to the application.
Here is what I wrote:
task/_form.php

Modal::begin(
    [
        'id' => 'modal',
        'size' => 'modal-lg',
        'header' => 'Выбор водителя',
        'toggleButton' => [
            'label' => 'Выбор',
            'options' => ['class' => 'btn btn-danger'],
        ],
    ]
);
echo $this->render('chooseDriver', ['task' => $model]);

Modal::end();

view/task/chooseDriver.php
<?= 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;
                }
            ]
        ],
    ]); ?>

But how do I accept values ​​in the controller? Or maybe there is a better way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LAV45, 2016-10-19
@LAV45

Try using kartik-v/yii2-editable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question