formam
formam copied to clipboard
Parsing checkbox value "on" as a bool
If I write an html form with a checkbox that has no explicit value attribute then when the checkbox is checked by the user the browser will send the string "on" in the form data. However, the string "on" is not recognized by strconv.ParseBool and I get a parse error. It would be nice if this library handled this case.
I realize that I can work around this by setting value="true" in my HTML form but I was wondering whether you would consider making that unnecessary by processing the string "on" as true when parsing booleans.
I'd have to check to be sure, but I'm pretty sure this should be handled: https://github.com/monoculum/formam/blob/master/formam.go#L501 – it doesn't call strconv.ParseBool() at all.
What does your HTML and code look like? Are you sure there isn't some error there? Also what error do you get?