radioButtonList() public static method

Generates a radio button list.
public static radioButtonList ( string $name, mixed $select, array $data, array $htmlOptions = [] ) : string
$name string name of the radio button list.
$select mixed selection of the radio buttons.
$data array $data value-label pairs used to generate the radio button list.
$htmlOptions array additional HTML attributes.
return string the generated list.
示例#1
0
 public function testRadioButtonList()
 {
     $I = $this->codeGuy;
     $html = TbHtml::radioButtonList('radioList', null, array('Option 1', 'Option 2', 'Option 3'), array('separator' => '<br>', 'container' => 'div', 'containerOptions' => array('class' => 'container')));
     $container = $I->createNode($html, 'div.container');
     $I->seeNodeChildren($container, array('label.radio', 'br', 'label.radio', 'br', 'label.radio'));
     $label = $container->filter('label')->first();
     $I->seeNodePattern($label, '/> Option 1$/');
     $input = $label->filter('input[type=radio]');
     $I->seeNodeAttributes($input, array('id' => 'radioList_0', 'name' => 'radioList', 'value' => '0'));
 }
示例#2
0
?>
    </div>
    <pre class="prettyprint linenums">
&lt;?php echo TbHtml::textArea('text', '', array('rows' => 3)); ?></pre>

    <h3>Checkboxes and radios</h3>

    <h4>Default (stacked)</h4>

    <div class="bs-docs-example">
        <?php 
echo TbHtml::checkBox('checkBox', '', array('label' => 'Option one is this and that—be sure to include why it\'s great'));
?>
        <br>
        <?php 
echo TbHtml::radioButtonList('optionsRadios', '', array('option1' => 'Option one is this and that—be sure to include why it\'s great', 'option2' => 'Option two can be something else and selecting it will deselect option one'));
?>
    </div>
    <pre class="prettyprint linenums">
&lt;?php echo TbHtml::checkBox('checkBox', '',
    array('label' => 'Option one is this and that—be sure to include why it\'s great')); ?>

&lt;?php echo TbHtml::radioButtonList('optionsRadios', '', array(
    'option1' => 'Option one is this and that—be sure to include why it\'s great',
    'option2' => 'Option two can be something else and selecting it will deselect option one',
)); ?></pre>

    <h4>Inline checkboxes</h4>

    <div class="bs-docs-example">
        <?php 
示例#3
0
 public function testUncheckValueOptionForCheckboxesAndRadioInputs()
 {
     $I = $this->codeGuy;
     $items = array(0);
     $model = new Dummy();
     $outputsWithHidden = array('checkbox' => TbHtml::checkBox('cb1', false, array('uncheckValue' => 1)), 'checkboxList' => TbHtml::checkBoxList('cb2', 0, $items, array('uncheckValue' => 1)), 'radio' => TbHtml::radioButton('rd1', false, array('uncheckValue' => 1)), 'radioList' => TbHtml::radioButtonList('rd2', 0, $items, array('uncheckValue' => 1)), 'activeCheckbox' => TbHtml::activeCheckBox($model, 'checkboxList'), 'activeCheckboxList' => TbHtml::activeCheckBoxList($model, 'checkboxList', $items), 'activeRadio' => TbHtml::activeRadioButton($model, 'radioList'), 'activeRadioList' => TbHtml::activeRadioButtonList($model, 'radioList', $items));
     foreach ($outputsWithHidden as $output) {
         $I->seeNodeChildren($I->createNode($output), array('input[type=hidden]'));
     }
     // comparing against null 'uncheckValue' option
     $noHiddenOptions = array('uncheckValue' => null);
     $outputsWithoutHidden = array('checkbox' => TbHtml::checkBox('cb1'), 'checkboxList' => TbHtml::checkBoxList('cb2', 0, $items), 'radio' => TbHtml::radioButton('rd1'), 'radioList' => TbHtml::radioButtonList('rd2', 0, $items), 'activeCheckbox' => TbHtml::activeCheckBox($model, 'checkboxList', $noHiddenOptions), 'activeCheckboxList' => TbHtml::activeCheckBoxList($model, 'checkboxList', $items, $noHiddenOptions), 'activeRadio' => TbHtml::activeRadioButton($model, 'radioList', $noHiddenOptions), 'activeRadioList' => TbHtml::activeRadioButtonList($model, 'radioList', $items, $noHiddenOptions));
     foreach ($outputsWithoutHidden as $output) {
         $I->dontSeeNodeChildren($I->createNode($output), array('input[type=hidden]'));
     }
 }