Skip to content

yii\bootstrap\Html cannot render Bootstrap styled controls #118

@yii-bot

Description

@yii-bot

This issue has originally been reported by @PowerGamer1 at yiisoft/yii2#10728.
Moved here by @klimov-paul.


There is a yii\bootstrap\Html class in Yii2 but it cannot render Bootstrap styled controls like radio buttons? For example:

echo Html::radio('a', false, ['label' => '111']);
echo Html::radio('b', false, ['label' => '222']);

gives the following markup:

<label><input name="a" type="radio" value="1">111</label>
<label><input name="b" type="radio" value="1">222</label>

instead of what Bootstrap expects:

<div class="radio"><label><input name="a" type="radio" value="1">111</label></div>
<div class="radio"><label><input name="b" type="radio" value="1">222</label></div>

It becomes even more problematic when trying to render a list of radio buttons using yii\bootstrap\Html::radioList().

It looks like the functionality to render proper Bootstrap layout for radio buttons is present in yii\bootstrap\ActiveField, but I think it should be moved to yii\bootstrap\Html instead.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions