Welcome Guest, Not a member yet? Register   Sign In
set_value/set_checkbox not keeping the checkbox checked if the form is reloaded.
#1

[eluser]Brad K Morse[/eluser]
code for creating the checkboxes step_id[] - it needs to have the name step_id[]

Code:
foreach ($steps as $r) {
  $step_checkbox = array(
      'name'            =>    'step_id[]',
        'id'                =>    'step_id_'.$r->SP_STEPS_ID,
        'value'            =>    $r->SP_STEPS_ID
  );

  if($r->SP_STEPS_OBJECTIVE_ID == $objective_id) {
    print '<div class="steps">';
    
        print '<p>'.form_checkbox($step_checkbox, set_value('step_id[]')).'</p>';
        
        print_r($step_checkbox);
        
    print '</div>';
  }
}

Screenshot of what it looks like

I also tried set_checkbox with no luck.

I copied this right from http://ellislab.com/codeigniter/user-gui...elper.html, and it didn't even work.

Code:
&lt;input type="checkbox" name="mycheck" value="1" &lt;?php echo set_checkbox('mycheck', '1'); ?&gt; /&gt;

The other fields in the form retain the data, but not the step_id[] checkbox, any help is appreciated.


Messages In This Thread
set_value/set_checkbox not keeping the checkbox checked if the form is reloaded. - by El Forum - 12-09-2010, 02:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB