diff --git a/zin/wg/btngroup/v1.php b/zin/wg/btngroup/v1.php index 98dc4a3278..6e203b7fd0 100644 --- a/zin/wg/btngroup/v1.php +++ b/zin/wg/btngroup/v1.php @@ -5,13 +5,22 @@ require_once dirname(__DIR__) . DS . 'btn' . DS . 'v1.php'; class btngroup extends wg { + static $defineProps = 'items?:array'; + + public function onBuildItem($item) + { + if(!($item instanceof item)) $item = item(set($item)); + return btn(inherit($item)); + } + protected function build() { - $btnGroup = h::div(setClass('btn-group')); - foreach($this->prop('btns') as $props) - { - $btnGroup->addChild(btn()->prop($props)); - } - return $btnGroup; + $items = $this->prop('items'); + return div( + setClass('btn-group'), + set($this->props->skip(array_keys(static::getDefinedProps()))), + is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : NULL, + $this->children() + ); } }