I have this radioList inline in Yii2:
<?= $form->field($model, 'abc')->inline(true)->radioList(array('1'=>'yes',2=>'no')); ?>
It generated:
<div class="form-group field-minstitution-abc">
<label class="control-label" for="abc">Abc</label>
<div>
<div id="abc">
<label class="radio-inline">
<input type="radio" name="abc" value="1"> yes
</label>
<label class="radio-inline">
<input type="radio" name="abc" value="2"> no
</label>
</div>
</div>
</div>
But I want the label inline with the radio button like this:
Use the folowing code.
form->field($model, 'abc',
['wrapperOptions' => ['style' => 'display:inline-block']])
->inline(true)->radioList(array('1'=>'yes',2=>'no'));
The wrapper option is applied to the div
tag with surrounds the radio buttons. The default display is block
, causing the div to use al of the available space pushing the label up. The function inline(true)
renders the radio buttons in one line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With