So from an array I can do this:
<?= Html::ul($array, ['class' => 'list-group']) ?>
How would I go about adding a class to the list items though?
So from an array I can do this:
<?= Html::ul($array, ['class' => 'list-group']) ?>
How would I go about adding a class to the list items though?
http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#ul()-detail
You can specify "itemOptions" option.
<?= Html::ul($array, ['class' => 'list-group', 'itemOptions' => ['class' => 'item-list']]) ?>
Or, if you want to specify different classes for items, you may use "item" option.
<?= Html::ul($array, ['class' => 'list-group',
'item' => function($item, $index) {
$class = $index == 0 ? 'first-item' : 'item';
return Html::tag('li', $item, ['class' => $class]);
}]) ?>