Open
Description
When rendering RadioButtonGroup with model that already has one of the valid options selected, ActiveField.php renders the label with 'active' CSS class added, which does not seem to be needed with BootStrap 5.x.
The result is that, whatever other option you select, the initially selected one still stays visually selected.
The fix is simple (attached .diff), but I'm not sure it does not break any other behaviour (so far haven't found any issues).
fix-activeform.diff.txt
--- ActiveField.php 2023-09-23 23:00:37.981027706 +0300
+++ ActiveField.php 2023-09-23 22:59:31.389222800 +0300
@@ -1833,7 +1833,7 @@
$wrapperOptions = ['class' => [$type.$css]];
}
if ($asBtnGrp) {
- if ($checked) {
+ if (($checked) and (!$isBs5)) {
Html::addCssClass($labelOpts, 'active');
}
$opts['autocomplete'] = 'off';
Sample code which shows the issue:
<?php
...
$types = array(1 => 'Type A', 2 => 'Type B');
$form->type = 1;
...
<?= $form->field($form, 'type')->radioButtonGroup( $types ); ?>
...
?>
Metadata
Metadata
Assignees
Labels
No labels