Answer the question
In order to leave comments, you need to log in
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
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',
],
]) ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question