Welcome Guest, Not a member yet? Register   Sign In
set_checkbox not working properly?
#1

[eluser]mrmuggles[/eluser]
I've got a really simple checkbox like that :

<input type="checkbox" name="newsletter" value="true" <?php echo set_checkbox('newsletter', 'true', false); ?> />

The function "set_checkbox" won't keep the state unless I add this line in my controller :

$this->form_validation->set_rules('newsletter', 'Newsletter', '');

Is that normal? Is there a more "logical" way to make it work?

Thanks!
#2

[eluser]verynewtothis[/eluser]
Yes it is..
but don't leave set_rules empty (nothing passed in 3rd parameter).. if its a non required field, you can always use rules like xss_clean|trim|alpha etc..




Theme © iAndrew 2016 - Forum software by © MyBB