AnswerDotAI / fasthtml

The fastest way to create an HTML app
https://fastht.ml/
Apache License 2.0
5.27k stars 219 forks source link

[BUG] All radio buttons in a radio group are checked during fill_form #423

Closed rbavery closed 3 weeks ago

rbavery commented 3 weeks ago

Describe the bug I'm trying to use fill_form with a radio group but when I refresh the page, fill_form sets both radios to checked, which means one radio is always shown as checked on the form on refresh rather than preserving the user choice.

Minimal Reproducible Example https://gist.github.com/rbavery/449916770f18cbd769389ab8b467d62b

python mre.py

Then follow the instructions on the page to toggle "True", refresh, and see that the form state is changed to False and the selection wasn't preserved.

Expected behavior On refresh, the radio selection should stay True

Environment Information Please provide the following version information:

Confirmation Please confirm the following:

Additional context I submitted a PR to fix this by checking to see if the value key of the radio input equals the val we get from the form state that should fill in the radio group.

this is the failing MRE where refreshing the page sets the selection from True to False failing_mre

jph00 commented 3 weeks ago

Fixed by #424 .