[eluser]Bramme[/eluser]
okay, I'm implementing that tonight :p
Can't access the svn folder from my work atm... Stupid proxy.
Did they include something to prepolute the checkboxes? Because my hacks are rather ugly at the moment. It seems to be working though.
This is smth from my controller:
Code:
if( $this->input->post('categories') != FALSE) {
$data['checkbox_array'] = $this->input->post('categories');
} else {
$this->db->where('tutID', $tutID);
$tutcats_query = $this->db->get('tutorial_categories');
foreach($tutcats_query->result() as $row) {
$selected_cats[] = $row->catID;
}
$data['checkbox_array'] = $selected_cats;
}
in my view i've got
Code:
<input type="checkbox" name="categories[]" value="<?=$cat['catID']?>" id="cat-<?=$cat['catID']?>" <?php echo $this->validation->set_checkbox_array($cat['catID'], $checkbox_array); ?>/>
And in MY_Validation.php
Code:
function set_checkbox_array($needle = '', $haystack = array())
{
if(empty($needle) OR empty($haystack))
{
return FAlSE;
}
else if (in_array($needle, $haystack))
{
return 'checked="checked"';
}
else
{
return FAlSE;
}
}