Skip to content

Bug: set_radio() in Form Helper does not work when radio button value equals "0" #2728

Description

@joshdentremont

If your radio button has the value "0" the set_radio() function will not output "checked='checked'" if that value had been clicked.

I believe this is because empty("0") returns true in the line at

if (! empty($input = $request->getPost($field)) || ! empty($input = old($field)))

If you add <input type="radio" name="myradio" value="0" <?php echo set_radio('myradio', '0'); ?> /> to a form you can see that it will not stay checked on submission.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions