Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
joshdentremont opened this issue Mar 20, 2020 · 3 comments · Fixed by #2729
Closed

Comments

@joshdentremont
Copy link

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.

@MGatner
Copy link
Member

MGatner commented Mar 20, 2020

You’re very right! Should be a quick fix plus a new test case. Thanks for reporting.

@musmanikram
Copy link
Contributor

musmanikram commented Mar 20, 2020

@MGatner will look into this. Did something similar in this PR

@musmanikram
Copy link
Contributor

@MGatner @joshdentremont PR is there. Same issue was in checkbox also. Fixed that too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants