[eluser]Samuurai[/eluser]
Hi,
I've spent an entire day trying to get this working and am hoping someone can shed a little light.
I have a form which I use the form_validation plugin with. The validation rules are working perfectly.
I use set_value and set_checkbox to repopulate the form. set_value is working fine, but none of my checkboxes repopulate.
Here is an example from my form:
Code:
<input type="checkbox" class="checkbox" id="hgv1" name="skills[]" value="hgv1" <?=set_checkbox('skills[]',@$result['hgv1'])?> />
<input type="checkbox" class="checkbox" id="hgv2" name="skills[]" value="hgv2" <?=set_checkbox('skills[]',@$result['hgv2'])?> />
here is the relevant parts of my controller:
Code:
function index()
{
if($this->input->post('submit'))
{
$this->_do_save();
}
else
{
$this->_populate_user_form();
}
$this->load->view('header', $data);
$this->load->view('user_form', $data);
$this->load->view('footer', $data);
}
function _do_save()
{
//SET VALIDATION RULES
$this->form_validation->set_rules('skills[]','Skills','callback_skill_check|xssclean');
if($this->form_validation->run())
{
//SAVE USER
}
}
function _populate_user_form()
{
// GET DATA FROM DB and pass to form
}