However, I seem to fail at marking the correct checkboxes as checked, so I'm surely doing something stupid..
Below is my code:
Code: Select all
foreach ($products_attributes['options_array'] as $options_value) {
$checked = '';
if (isset($_GET['attrib_' . $products_attributes['options_id']]) && $_GET['attrib_' . $products_attributes['options_id']] === $options_value['products_options_values_id']) $checked = 'checked';
$attribute_filter .= new Tickable('attrib_' . $products_attributes['options_id'], [
'value' => $options_value['products_options_values_id'],
'id' => 'po-id-' . $options_value['products_options_values_id'],
'aria-describedby' => $options_value['products_options_values_name'],
'class' => 'custom-control-input filter-input filter-' . $products_attributes['options_id'],
'onchange' => 'this.form.submit()',
$checked => '',
], 'checkbox');
...I expected the loop to reset the 'checked' => 'checked' thing, but I guess it is not, and I don't know how to correct it - can someone maybe help?
(There might a lot of other problems with my code - I don't really know what I'm doing, but usually I manage to try enough times to make it work. Suggestions for improvements on other stuff is welcome as well, but the main thing is the checkbox-checking)
//Daniel