4

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

Dat Lam
  • 161
  • 1
  • 6
  • 17

2 Answers2

4

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.

arogachev
  • 33,150
  • 7
  • 114
  • 117
  • Thank you, but the genegated output is:
    and i want change tag
    to
    – Dat Lam Apr 03 '15 at 03:41
  • I tested this right now and the output is exactly as I wrote in the question. Show the rest of the code, maybe you missed something. – arogachev Apr 03 '15 at 03:43
2

I think this is proper solution

<?= $form->field($model, 'abc')->inline()->radioList(['example1' => 'example1', 'example2' => 'example2'])->label(false) ?>
fool-dev
  • 7,671
  • 9
  • 40
  • 54