[eluser]marlar[/eluser]
Hi,
Being still new to CI it is sometimes difficult to know if I am doing something wrong or if I happened to find a bug. In this case I believe I found a bug in the validation library.
The problem is that checkboxes don't get re-populated if they are part of a group, like:
Code:
echo form_checkbox('group[]','family', $this->validation->set_checkbox('group', 'family'));
echo form_checkbox('group[]','friends', $this->validation->set_checkbox('group', 'friends'));
I changed set_checkbox() in the validation libary to:
Code:
function set_checkbox($field = '', $value = '')
{
if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
{
return '';
}
//Before: if ($_POST[$field] == $value)
if ($_POST[$field] == $value || ( is_array($_POST[$field]) && in_array($value, $_POST[$field])) )
{
return ' checked="checked"';
}
}
and now it seems to work as expected.