CheckboxInput should render 'False' value as unchecked
|Reported by:||bthomas||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, BooleanField will accept a value of 'False' and convert it to a boolean False in cleaned_data, for the case where it accepts data from a hidden field. However, if it is rendered as a CheckboxInput widget again, it will be rendered as checked, as the string 'False' from the initial data is converted to a True value.
Failed example: w.render('is_cool', 'False') Expected: u'<input type="checkbox" name="is_cool" />' Got: u'<input checked="checked" type="checkbox" name="is_cool" value="False" />'
This was happening to me in a strange case of a form validating for the preview stage of FormPreview, but failing validation after the POST, but there are probably other cases where someone might want to render a hidden value of 'False' into a CheckboxInput.
Change History (14)
Changed 7 years ago by bthomas
comment:1 Changed 7 years ago by bthomas
- Cc cpawlukosky@… added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
Changed 6 years ago by bthomas
comment:10 Changed 6 years ago by jkocherhans
- Resolution set to fixed
- Status changed from new to closed