Answer the question
In order to leave comments, you need to log in
Why does DetailView not want to work with custom columns?
I'm trying to render a boolean field:
echo DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'is_completed',
'class' => 'yii\grid\CheckboxColumn',
]
]
]);
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Why doesn't he want to. It works, it displays 0/1 for you.
What do you want to do?
Add 'value' and substitute 0 and 1
Try this.
'value' => ArrayHelper::getValue($model->attribute,[0 => 'No', 1 => 'Yes'])
yii\grid\CheckboxColumn is for GridView.
Binds to rows in the table, not to a specific attribute.
Checkbox column displays the column as a checkbox...
Users can click on the checkboxes to select rows in the table.
echo DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'is_completed',
'format' => 'raw',
'value' => Html::checkbox('is_completed', $model->is_completed, ['disabled'=>true])
]
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question