S
S
skajtersen2017-06-12 10:11:34
Yii
skajtersen, 2017-06-12 10:11:34

How to pass get parameter from view1 to view2?

I have view1, which has an active form field, where you can enter the product id and, by clicking the submit button, see all the information about the product.
I also have view2, in which, using gridview, a table is displayed - the id of the product with its name.
I have a question. How can I turn the product id in view2 into a link, when clicked, a transition to view1 would occur, and the id itself as a get-parameter would be inserted into the activeform field and the submit button would be pressed immediately?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-06-12
@skajtersen

The link can be generated like this:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        [
            'attribute' => 'id',
            'content' => function ($model, $key, $index, $column) {
                $url = \yii\helpers\Url::toRoute(['url', 'id' => $model->id]);
                return Html::a($model->id, $url);
            }
        ]
        'name',
    ],
]) ?>

instead of URL - must be the address of the controller responsible for displaying information about the product

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question