Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/styllloz/public_html/qa-include/qa-base.php on line 1175

Warning: session_start(): Cannot start session when headers already sent in /home/styllloz/public_html/qa-include/app/users.php on line 162

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/users.php on line 1267

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/page.php on line 356
In yii2 format in the gridview row to remove empty option? - code-flow.club | Q&A

In yii2 format in the gridview row to remove empty option?


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
134 views
In gridview I made a drop down list which you can use to display published and unpublished posts

[ 'attribute' => 'status', 'format' => 'raw', 'filter' => [ 'off' => 'Not published', 'on' => 'Published', ], 'headerOptions' => ['width' => '200'], 'value' => function ($model, $key, $index, $column) { $status = $model->status === 'on'; return \\yii\\helpers\\Html::tag( 'span', $status ? 'Published' : 'Not published', [ 'class' => 'label label-' . ($status ? 'success' : 'danger'), ] ); }, ],


In this drop down list will fall more and empty option
Not publishedPublished

How to exclude it?
by | 134 views

1 Answer

0 like 0 dislike
You can not pass an array and a string in which the finished html for the cell filter, and there too, that want a city. If you're interested how it works, here's the source code:
\rhttps://github.com/yiisoft/yii2/blob/master/framew...
Alternatively, you can create your yii\\grid\\DataColumn and alter this method to your liking.

But I think the goal itself is not quite adequate. You bring to the table all the values so they do not set a filter, so there must be an empty variant. You will not be able to select all records will have either published or not. Why take away user functionality?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 10, 2019 by cloudz
110,608 questions
257,186 answers
0 comments
35,181 users