![]() |
CodeIgniter form set_radio bug? - 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: CodeIgniter form set_radio bug? (/showthread.php?tid=28893) |
CodeIgniter form set_radio bug? - El Forum - 03-24-2010 [eluser]dignick[/eluser] I'm using set_radio to fill in a radio field. If the value of the radio is 0, then CodeIgniter will not set the radio to checked. The reason for this is that the value being passed to set_radio is a numerical 0 and the condition (0 == '') returns true, which is tested near the bottom of the set_radio function in the Form_validation library: Code: if (($field == '' OR $value == '') OR ($field != $value)) It is the $value == '' test that is the problem here. If this is changed to $value === '' the field gets checked as expected. The problem is set_radio expects a string to be passed to it, but should it not also work with a number? CodeIgniter form set_radio bug? - El Forum - 03-24-2010 [eluser]dignick[/eluser] Another way to prevent this issue is to cast the passed $value parameter as a string when passing it. Shouldn't this be dealt with in CodeIgniter though? |