Open kuhler-Stratege opened 2 months ago
Checking the source code for 'checked' section, I see:
if checked !== null {
if !fetch value, attributes["value"] {
let value = null;
}
if checked === value {
let attributes["checked"] = "checked";
}
}
this means that you should be using checked with the same as the value and only on the one you need checked, something like
$radio1 = new Radio('radio_all', [
'name' => 'is_active',
'value' => '',
'checked' => ''
]);
$radio1->setLabel('All');
$this->add($radio1);
$radio2 = new Radio('radio_active', [
'name' => 'is_active',
'value' => '1',
]);
$radio2->setLabel('Active');
$this->add($radio2);
Describe the bug In my project, I created a UI similar to the search page of PHPMyAdmin, where you can filter by different values of an sql table. This is done using several Radiogroups. When the user does not want to filter by a certain column, the value of the radio is an empty string. As default, all entries of an sql table are shown on that page, so per default the Radio with the empty string as value should be selected. \ This is the bug: It does not. When I add an empty string as default and as
checked
attribute, the Radio is still not checked by default and I need to manually hack thechecked
flag into the html after rendering.To Reproduce
Steps to reproduce the behavior:
Expected behavior The rendering of the radio should flag the radio with the empty string as value to be checked if it matches the default or the selected value.
Details