Opened 11 years ago
Last modified 11 years ago
#20684 closed New feature
Support form element attributes with no value — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | loic@…, shai@…, jcd@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are a couple of form attributes such as required that was introduced in HTML5 that should not contain a value. For exaple required="required" is valid but for example required="true" will result in failed validation with true being marked as a bad value.
The correct use would be:
<input type="email" required />
Currently in forms.py attributes cannot be specified without a value which rely on the author knowing that a value of 'true' not being valid but 'required' being ok. it would be great if Django supports valueless attributes.
Perhaps doing:
widget=forms.TextInput(
attrs={
'required':
}))
will result in an input of:
<input type="text" required />