Hi,
I am producing an edit form. This form will enable a user to edit a product.
The product may support many platforms. To enable a user to choose a variety of platforms it was decided that checkboxes would be the best option.
This is my code:
while ( $row = $db->getObject() ) { // this is ALL the possible platforms from the database
foreach ($platforms as $k => $v) { // this is to iterate through the checkboxes that hav been stored for this product
if ($row->platform_id == $v) {
$form->addCheckbox( 'platform[]', $row->platform_name, $row->platform_id, TRUE );
}
}
}
The problem with this is that the user will now only see the checkboxes that they had originally chosen when entering the product.
Now they are coming to edit the product they should see all available platforms, and have checks in the checkboxes that were originally selected.
The problem as I see it with my code is the nesting of loops but I don't know how to achieve the same without doing so. But that said, I know that getting this working is very common place so its a case of me being stoopid.
I hope that makes sense.
Can anyone help please ? I have been smacking my head against a wall for hours on this.