buttonToolbar() public static method

Generates a button toolbar.
public static buttonToolbar ( array $groups, array $htmlOptions = [] ) : string
$groups array the button group configurations.
$htmlOptions array additional HTML options.
return string the generated button toolbar.
Beispiel #1
0
echo TbHtml::buttonGroup(array(array('label' => 'Left'), array('label' => 'Middle'), array('label' => 'Right')));
?>
	</div>
	<pre class="prettyprint linenums">
&lt;?php
echo TbHtml::buttonGroup(array(
    array('label' => 'Left'),
    array('label' => 'Middle'),
    array('label' => 'Right'),
)); ?></pre>

	<h3>Multiple button groups</h3>

	<div class="bs-docs-example">
		<?php 
echo TbHtml::buttonToolbar(array(array('items' => array(array('label' => '1'), array('label' => '2'), array('label' => '3'), array('label' => '4'))), array('items' => array(array('label' => '5'), array('label' => '6'), array('label' => '7'))), array('items' => array(array('label' => '8')))));
?>
	</div>

	<pre class="prettyprint linenums">
&lt;?php echo TbHtml::buttonToolbar(array(
    array(
        'items' => array(
            array('label' => '1'),
            array('label' => '2'),
            array('label' => '3'),
            array('label' => '4'),
        ),
    ),
    array(
        'items' => array(
Beispiel #2
0
 public function testButtonToolbar()
 {
     $I = $this->codeGuy;
     $groups = array(array('items' => array(array('label' => '1', 'color' => TbHtml::BUTTON_COLOR_DANGER), array('label' => '2'), array('label' => '3'), array('label' => '4')), 'htmlOptions' => array('color' => TbHtml::BUTTON_COLOR_INVERSE)), array('items' => array(array('label' => '5'), array('label' => '6'), array('label' => '7'))), array('visible' => false, 'items' => array(array('label' => '8'))), array('items' => array()));
     $html = TbHtml::buttonToolbar($groups, array('class' => 'div', 'color' => TbHtml::BUTTON_COLOR_PRIMARY));
     $toolbar = $I->createNode($html, 'div.btn-toolbar');
     $I->seeNodeCssClass($toolbar, 'div');
     foreach ($toolbar->children() as $i => $groupElement) {
         $group = $I->createNode($groupElement);
         $I->seeNodeCssClass($group, 'btn-group');
         foreach ($group->children() as $j => $btnElement) {
             $btn = $I->createNode($btnElement);
             $I->seeNodeCssClass($btn, 'btn');
             if ($i === 0) {
                 $I->seeNodeCssClass($btn, $j === 0 ? 'btn-danger' : 'btn-inverse');
             } else {
                 $I->seeNodeCssClass($btn, 'btn-primary');
             }
             $I->seeNodeText($btn, $groups[$i]['items'][$j]['label']);
         }
     }
     $html = TbHtml::buttonToolbar(array());
     $this->assertEquals('', $html);
 }