CheckboxInput should render 'False' value as unchecked
|Reported by:||Bob Thomas||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)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|