Welcome Guest, Not a member yet? Register   Sign In
Re-populating checkboxes from DB (field as Array)


I'm trying to use the new Form Validation class. I don't know if you have come across this, but here's my case:

I have a view that outputs the checkboxes, like this:
<?php foreach($subtemas as $subrow): ?>
<input type="checkbox" name="temas[]" value="<?=$subrow->tem_id?>" <?=set_checkbox('temas[]',$subrow->tem_id)?> /> <?=$subrow->tem_nome?>
<br />
&lt;?phpendforeach; ?&gt;

'tem_id' is the item ID and 'tem_nome' is the item Name. 'temas[]' is the array field.
The set_checkbox() function works to repopulate the form after the validation fails.

The problem is: how do I repopulate these checkboxes from the DB? I've tried to use $this->form_validation->set_checkbox() from the controller but it doesn't seem to work. I've tried to assign values to the $_POST array but with no results as well.

Anyone having this problem too?

Thanks in advance Smile

Theme © iAndrew 2016 - Forum software by © MyBB