Yii2 : Setting two values of Key in SqlDataProvider -
i have table have_schedule
(many-to-many relations) in database contains foreign key tables :
table student : student_id, student_name
table schedule : sch_id, sch_day, sch_time
and
table have_schedule : student_id, sch_id
and want create dataprovider
using sqldataprovider
this
$dataprovider = new sqldataprovider([ 'sql' => $sql, 'totalcount' => $n, 'key' => '', // <--------- key 'sort' => [ 'attributes' => [ 'student_name', 'sch_day', 'sch_time', ], ], 'pagination' => [ 'pagesize' => 20, ], ]);
the key used actioncolumn
, example : /view?student_id=1&sch_id=2
.
how set key's value student_id
, sch_id
?
the simplest way not create/use actioncolumn, instead can use raw-column , show there want:
[ 'attribute' => 'some_title', 'format' => 'raw', 'value' => function ($model) { return '<a href="'.$yoururl .'">your text</a>'; }, ],
Comments
Post a Comment