M
M
Monitorkin2017-04-06 09:55:08
css
Monitorkin, 2017-04-06 09:55:08

Checkbox + label in Gridview how to display?

Hello, this code:

GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
          [
            'class' => 'yii\grid\CheckboxColumn',
            'checkboxOptions' => function ($model, $key, $index, $column) {
              return ['checked' => $model->published];
            }
              ],
...

displays the following checkbox:
<input type="checkbox" name="selection[]" value="120" checked="">

there was a desire to style it, but all examples are based on the checkbox label.
Question: how to display the checkbox from the label?
to make it look like this:
<label>
      <input type="checkbox" name="selection[]" value="120" checked="">
</label>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-04-06
@Monitorkin

use the content property , like so:

[
    'class' => 'yii\grid\CheckboxColumn',
    'content' => function ($model, $key, $index, $column) {
        $checkbox = // генерируем какой-угодно чекбокс
        return $checkbox;
    }
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question