本文介绍了yii2 无线电内联 Html 助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 yii2 中有这个 radioList

Html::radioList('abc',null,$new,['class' => 'form-control input-sm']);

它生成这个:

但我想要:

请帮帮我

解决方案

没有.假设 $new = [1 =>'你好', 2 =>'世界'];

生成的输出将是:

<标签><input type="radio" name="abc" value="1">你好<标签><input type="radio" name="abc" value="2">世界

如果您想将 radio 类添加到容器标签,您可以这样做:

echo Html::radioList('abc', null, $new, ['class' => 'form-control input-sm radio']);

对于每个输入,它将是:

echo Html::radioList('abc', null, $new, ['类' =>'form-control input-sm','itemOptions' =>['类' =>'收音机'],]);

查看文档,很清楚.

I have this radioList in yii2

Html::radioList('abc',null,$new,['class' => 'form-control input-sm']);

It generates this:

<div class=radio>

but I want:

<div class=radio-inline>

please help me

解决方案

No. Let's say that $new = [1 => 'Hello', 2 => 'World'];

The generated output will be:

<div class="form-control input-sm">
    <label>
        <input type="radio" name="abc" value="1"> Hello
    </label>

    <label>
        <input type="radio" name="abc" value="2"> World
    </label>
</div>

If you want to add radio class to container tag you can do it like that:

echo Html::radioList('abc', null, $new, ['class' => 'form-control input-sm radio']);

For each input it will be:

echo Html::radioList('abc', null, $new, [
    'class' => 'form-control input-sm',
    'itemOptions' => ['class' => 'radio'],
]);

Check the documentation, it's pretty clear.

这篇关于yii2 无线电内联 Html 助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 13:58