I have a requirement of displaying the Progress Bar in DetailView
widget. I searched for it but I got solutions for GridView
widget. So that I tried modifying it but didn't work as expected.
<?=DetailView::widget(
[
'model' => $model,
'attributes' =>
[
[
'attribute' => 'progress',
'label' => 'Activity Progress',
'type' => DetailView::INPUT_WIDGET,
'class' => 'yii\bootstrap\Progress',
'widgetOptions' =>
[
'percent' => 50,
'barOptions' => ['class' => 'progress-bar-info'],
'options' => ['id' => 'progBar', 'class' => 'active progress-striped']
]
]
]
]
)
?>
You need to simply set the column
format
toraw
and return the widget output from thevalue
option simple as that see below I used theyii\bootstrap\Progress
widget within theDetailView
If you have a field in the database with the name
progress
that holds the current progress of the row in integer format you can pass$model->progress
to thepercent
option in theyii\bootstrap\Progress
widget like"percent"=>$model->progress
.