Load a radio buttons list using HTMLHelper('select.radiolist') and pass a CSS class in the attributes.
$options=array();
$o = new stdClass();
$o->value = 1;
$o->text = 'option 1';
$options[] = $o;
$attribs=array();
$attribs['class'] = 'MyCLass'
HTMLHelper::_('select.radiolist', $options, 'fieldname', $attribs);
Both the form-check-input
and MyCLass
should be merged in one class attribute
<div class="controls">
<div class="form-check form-check-inline">
<input type="radio" class="form-check-input MyCLass" name="fieldname" id="fieldname1" value="1">
<label for="fieldname1" class="form-check-label" id="fieldname1-lbl">option 1</label>
</div>
</div>
class
attribute is duplicated.
<div class="controls">
<div class="form-check form-check-inline">
<input type="radio" class="form-check-input" name="fieldname" id="fieldname1" value="1" class="MyCLass">
<label for="fieldname1" class="form-check-label" id="fieldname1-lbl">option 1</label>
</div>
</div>
Modern browser will remove the second instance of the class attribute and that can cause developper headaches...
This is in particular an issue with Virtuemart that is loading some radio list and then some script is looking for the selected option based on a passed class but the class has been removed by the browser (or some cleanup / compress html scripts)
Php 8.1
Joomla 4.3.3
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
.=
is for string concatenation. It is fine since it is for an array.
That would not work since the function Select.radiolist is hardcoding the class "form-check-input" to the input
You can refer to file : /libraries/src/HTML/Helpers/Select.php
if (is_array($attribs)) { $attribs = ArrayHelper::toString($attribs); }
$html .= '<input type="radio" class="form-check-input" name="' . $name . '" id="' . $id . '" value="' . $k . '" ' . $extra . $attribs . '>';
Labels |
Added:
bug
|
I am changing this from a bug to a feature request. The HTMLHelper('select.radiolist') does not support the addition of an extra css class as you have seen so its not a bug
Labels |
Added:
Feature
Removed: bug |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-04-27 15:52:02 |
Closed_By | ⇒ | richard67 |
Shouldnt the code be as follows?
$attribs['class'] .= 'MyCLass'