S
S
Silverviql2018-04-28 16:17:57
Yii
Silverviql, 2018-04-28 16:17:57

Is it possible to anchor on redirect in PHP?

I have a table in it, the rows have data-key="11" where 11 is the id in the database.
The redirect looks like this: return $this->redirect(['todoist/index', 'id' => $model->id_zakaz]); But since I don’t have a page with tasks, there is nowhere to return by id, so I want it to be redirected to the task page and go to the table row as an anchor.
How can I add another anchor to it on data-key="11" :?
If I explained something in Chinese, ask). Thank you.
5ae47479129fa907869170.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-04-28
@Silverviql

Good evening.
Approximately so
Translates to the index page, to <div id="custom-order-form">
PS
For the string, set the id parameter, which will contain the id of the entry in the database. Let this be the "id" column in the GridView, although this can be set for any cell.

[
    'attribute' => 'id',
    'headerOptions' => ['class' => 'head-id-column'],
    'contentOptions' => function($model){
           return ['id' => 'test-' . $model->id];
        }
],

Further, in the controller we register redirect with the necessary parameter.
That's it, the "anchor" is ready.
PS
Or. Don't do 'contentOptions', but do 'rowOptions'.
GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'rowOptions' => function($model){
            return ['id' => 'test-' . $model->id];
        },
        'columns' => [
            // остальной код
         ],
    ]);

D
Dmitry, 2018-04-28
@demon416nds

it is possible
but IMHO it is more convenient to use
how to deal with other people's classes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question