Hi guys, I'm loving the framework. Thanks for all your work on it.
It looks like I may have found a bug in the Form::radio function. I'm not sure if this is known already or not. I'm using Fuelphp 1.4.
Here's my code: <code>test: <?php echo Form::radio('public', '0', false); ?></code>
This returns the following html: <code><inputid="form_public"type="radio"checked="checked"value="0"name="public"></code>
Passing '0' as the second (value) param and boolean false as the third (checked) param results in a checked radio button. It looks like the offending bit of code is in core/classes/form/instance.php starting at line 300.
<code> if ( ! is_array($checked)) { // If it's true, then go for it if (is_bool($checked) and $checked === true) { $attributes['checked'] = 'checked'; }
// Otherwise, if the string/number/whatever matches then do it elseif (is_scalar($checked) and $checked == $value) { $attributes['checked'] = 'checked'; } } </code>
Moving the check for true inside the is_bool if statement seems to solve the problem like this: <code> if (is_bool($checked)) { if( $checked === true ) { $attributes['checked'] = 'checked'; } } </code>
That way false booleans don't continue on to the is_scalar check.
Am I doing something stupid (definitely a possibility) or is this actually a bug?