public function list_group()
{
return _class('html')->list_group([
'First line',
[
'body' => 'Cras justo odio',
'badge' => '14',
],
[
'body' => 'Dapibus ac facilisis in',
'badge' => '2',
'class_item' => 'active',
],
[
'body' => 'Morbi leo risus',
'badge' => '1',
'class_item' => 'list-group-item-warning',
],
]);
}
public function list_group($data = [], $extra = [])
{
$extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$items = [];
foreach ((array) $data as $v) {
if ( ! is_array($v)) {
$body = $v;
$v = [];
} else {
$body = $v['body'];
}
$type = $v['type'] ?: $extra['type'];
$class_item = $v['class_item'] ?: $extra['class_item'];
$items[] = '<li class="list-group-item' . ($class_item ? ' ' . $class_item : '') . '"><span class="badge">' . $v['badge'] . '</span> ' . $body . '</li>';
}
return '<ul class="list-group' . ($extra['class'] ? ' ' . $extra['class'] : '') . '" id="' . $extra['id'] . '">' . implode(PHP_EOL, (array) $items) . '</ul>';
}