Answer the question
In order to leave comments, you need to log in
How to add new tags to table in gridView?
I have a code in the gridView, but using the example https://dev-tips.ru/blog/post/gridview-v-yii2-pros... two options were indicated as yes and no, I converted them a bit and got me this code
[
'attribute' => 'status',
'format' => 'raw',
'value' => function($model, $key, $index, $column){
$active = $model->{$column->attribute} == 0;
return Html::tag(
'div',
$active ? 'Новый' : 'В работе',
[
'class' => 'label label-'.($active ? 'primary' : 'success'),
]
);
},
'headerOptions' => ['width' => '50'],
],
switch ($status) {
case '0':
'Новый'
break;
}
Answer the question
In order to leave comments, you need to log in
Good evening.
In the model, you create a public, static method, where you prescribe all nine parameters.
In gridview call this method and get dropdown list
Hello.
Try adding format='raw' to the hollow.
This will display the tags.
He gave an example below:
...
'columns' => [
[
'attribute' => 'id',
'value' => 'id',
'contentOptions' => ['width' => '20px'],
],
[
'attribute' => 'name',
'format' => 'raw',
'value' => function ($data) {
$fieldValue = '<strong>'.$data->name.'</strong>';
return $fieldValue;
},
'contentOptions' => ['width' => '150px'],
],
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question