TbHtml::activeRadioButton PHP Method

activeRadioButton() public static method

Generates a radio button for a model attribute.
public static activeRadioButton ( CModel $model, string $attribute, array $htmlOptions = [] ) : string
$model CModel the data model.
$attribute string the attribute.
$htmlOptions array additional HTML attributes.
return string the generated radio button.
    public static function activeRadioButton($model, $attribute, $htmlOptions = array())
    {
        $label = TbArray::popValue('label', $htmlOptions, false);
        $labelOptions = TbArray::popValue('labelOptions', $htmlOptions, array());
        $input = parent::activeRadioButton($model, $attribute, $htmlOptions);
        if (TbArray::popValue('useContainer', $htmlOptions, false)) {
            return self::tag('div', array('class' => 'radio'), self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions));
        } else {
            return self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions);
        }
    }

Usage Example

Exemplo n.º 1
0
 public function testActiveRadioButton()
 {
     $I = $this->codeGuy;
     $html = TbHtml::activeRadioButton(new Dummy(), 'radio', array('class' => 'input', 'label' => 'Label text'));
     $body = $I->createNode($html, 'body');
     $hidden = $body->filter('input[type=hidden]');
     $I->seeNodeAttributes($hidden, array('id' => 'ytDummy_radio', 'name' => 'Dummy[radio]', 'value' => '0'));
     $label = $body->filter('label');
     $I->seeNodeCssClass($label, 'radio');
     $radio = $label->filter('input[type=radio]');
     $I->seeNodeAttributes($radio, array('class' => 'input', 'checked' => 'checked', 'id' => 'Dummy_radio', 'name' => 'Dummy[radio]', 'value' => '1'));
     $I->seeNodePattern($label, '/> Label text$/');
 }
All Usage Examples Of TbHtml::activeRadioButton
TbHtml