yii2-bootstrap4 icon indicating copy to clipboard operation
yii2-bootstrap4 copied to clipboard

radioList doesn't respect radioTemplate option

Open DmLapin opened this issue 4 years ago • 0 comments

What steps will reproduce the problem?

In my container I set this definition:

'definitions' => [
    'radioOptions' => [
        'class' => ['widget' => 'form-check-input'],
        'labelOptions' => [
            'class' => ['widget' => 'form-check-label']
        ],
    ],
    'radioTemplate' => "<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>",
]

In my view:

$activeForm->field($someForm, 'someField')->radioList($someValues);

What's expected?

<div role="radiogroup">
    <div class="form-check">
        <input type="radio" id="i0" class="form-check-input" name="SomeForm[someField]" value="1">
        <label class="form-check-label" for="i0">Label 1</label>
    </div>

    <div class="form-check">
        <input type="radio" id="i1" class="form-check-input" name="SomeForm[someField]" value="2">
        <label class="form-check-label" for="i1">Label 2</label>
    </div>
...
</div>

What do you get instead?

<div role="radiogroup">
    <div class="custom-control custom-radio">
        <input type="radio" id="i0" class="form-check-input" name="SomeForm[someField]" value="1">
        <label class="form-check-label" for="i0">Label 1</label>
    </div>

    <div class="custom-control custom-radio">
        <input type="radio" id="i1" class="form-check-input" name="SomeForm[someField]" value="2">
        <label class="form-check-label" for="i1">Label 2</label>
    </div>
...
</div>

Additional info

Same thing with checkboxList. Yes, I have found in code magic 'wrapperOptions', on vendor/yiisoft/yii2-bootstrap4/src/ActiveField.php:381 but:

  1. No mention about it in phpdoc for $radioOptions.
  2. Why should I configure radios & checkboxes layout twice?

Maybe it's not bug, but doc problem.

DmLapin avatar Sep 08 '20 09:09 DmLapin