Why does this code only check the first checkbox?
$activetheme = $theme->selectActiveThemeName();
foreach($blocks->availableBlockAreas($activetheme) as $block_name => $block_area_number) {
$selected = (in_array($block_area_number, $block_areas)) ? ' checked="checked"' : '';
echo '<p><input class="block_checkboxes" '. $selected .' type="checkbox" name="block_areas[]" value="'.$block_area_number.'" />'.ucfirst($block_name).'</p>';
}
$block_areas is an array:
Array ( [0] => 1,2,3 )
$blocks->availableBlockAreas($activetheme) returns
Array ( [Homepage - Left Column] => 1 [Homepage - Right Column] => 2 [Custom Page - Left Column] => 3 [Custom Page - Right Column] => 4 )
The $block_area_number should iterate?
EDIT:
After Geoandri' answer i came up with this fix, first i serialized the array when inserting into the DB then:
$block_areas[] = unserialize($row['block_areas']);
$selected = (in_array($block_area_number, $view->array_flatten($block_areas))) ? ' checked="checked"' : '';