Html Yii2自定义yii\bootstrap4\ActiveField::radioList选项

Html Yii2自定义yii\bootstrap4\ActiveField::radioList选项,html,yii2,radio,Html,Yii2,Radio,我正在使用yii\bootstrap4\ActiveField::radioList,并试图在我的radioList的选项中插入html标记 有没有一种不创建模板的直接方法?您需要的是一个选项,它可以让您轻松地自定义收音机或复选框输入和标签 虽然不清楚您试图为放射科医生遵循什么布局,但您可以在下面的代码中进行更改,我将重点介绍您提到的内容,即为放射科列表输入设置文本标签的格式 $list = [ 0 => '<strong>Option1</strong>&

我正在使用yii\bootstrap4\ActiveField::radioList,并试图在我的radioList的选项中插入html标记


有没有一种不创建模板的直接方法?

您需要的是一个选项,它可以让您轻松地自定义收音机或复选框输入和标签

虽然不清楚您试图为放射科医生遵循什么布局,但您可以在下面的代码中进行更改,我将重点介绍您提到的内容,即为放射科列表输入设置文本标签的格式

$list = [
    0 => '<strong>Option1</strong><br>lorem ipsum lorem ipsum',
    1 => '<strong>Option2</strong><br>lorem ipsum lorem ipsum',
    2 => '<strong>Option3</strong><br>lorem ipsum lorem ipsum,',
];

echo $form->field($model, 'field')
    ->radioList(
        $list,
        [
            'item' => function ($index, $label, $name, $checked, $value) {

                $html = '<label >';
                $html .= '<input type="radio" name="' . $name . '" value="' . $value . '" ' . $checked . '>';
                $html .= '<span>' . ucwords($label) . '</span>';
                $html .= '</label>';

                return $html;
            },
        ]
    )
    ->label('Your choose?');
$list = [
    0 => '<strong>Option1</strong><br>lorem ipsum lorem ipsum',
    1 => '<strong>Option2</strong><br>lorem ipsum lorem ipsum',
    2 => '<strong>Option3</strong><br>lorem ipsum lorem ipsum,',
];

echo $form->field($model, 'field')
    ->radioList(
        $list,
        [
            'item' => function ($index, $label, $name, $checked, $value) {

                $html = '<label >';
                $html .= '<input type="radio" name="' . $name . '" value="' . $value . '" ' . $checked . '>';
                $html .= '<span>' . ucwords($label) . '</span>';
                $html .= '</label>';

                return $html;
            },
        ]
    )
    ->label('Your choose?');