Is it possible to make an anchor when you redirect in PHP?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
I have a table in this row are data-key="11" where 11 is the id in the database.
Redirect looks like this: return $this->redirect(['todoist/index', 'id' => $model->id_zakaz]); But since I have no page with nowhere to return task by id, so I want him to be redirected to the task page and the anchor moved on to the row of the table.
How can I add another anchor to data-key="11" :?
If I like the Chinese explained ask). Thank you.

by | 15 views

2 Answers

0 like 0 dislike
Good evening.
Approximately so
return $this->redirect(['index', '#' => 'custom-order-form']);

Go to the index page,

For lines specify the id parameter, which will contain the record id in the database. Let it be a column "id" in the GridView table though so the value may be specified for any cell.
[ 'attribute' => 'id', 'headerOptions' => ['class' => 'head-id-column'], 'contentOptions' => function($model){ return ['id' => 'test-' . $model->id]; } ],

Further, in the controller prescribes the redirect with the desired parameter.
return $this->redirect(['index', '#' => 'test-' . $id]);

All the "anchor" is ready.

P. S. S
Or. 'Don't do 'contentOptions', and make 'rowOptions'.
GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function($model){ return ['id' => 'test-' . $model->id]; }, 'columns' => [ // rest of code ], ]);
0 like 0 dislike
but IMHO easier to use
header("Location:"); /* Redirect browser */

than to understand other people's classes

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked Jun 5, 2019 by Leshiy66613
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
40,796 users