CodeIgniter Forums
Checkbox ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Checkbox ? (/showthread.php?tid=37827)



Checkbox ? - El Forum - 01-21-2011

[eluser]fuji2009[/eluser]
Hello guys, i don t understand how work checkbox i do it :

View :
Code:
<tr>
                <td>
                &lt;input type="checkbox" name="mycheck" value="&lt;?php echo set_value('mycheck');?&gt;" &gt;
                &lt;/td>
                </tr>
                <tr><td>&lt;?php echo form_error('mycheck','<div class="error">','</div>');?&gt;</td></tr>

and my controller :

Code:
$this->form_validation->set_rules('mycheck', 'Mycheck', 'required');

But the error work when i validate without check the box but when i check the box error again..


can you help me ? thanks you


Checkbox ? - El Forum - 01-21-2011

[eluser]RedIgniter[/eluser]
I don't believe you need to set a value for the checkbox through php, just have it some value like accept and check if $this->input->post('mycheck') == "accept"

let me know if it worked