Opened 11 years ago

Last modified 11 years ago

#20684 closed New feature

Support form element attributes with no value — at Version 1

Reported by: sneethling@… 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 (last modified by Claude Paroz)

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 />

Change History (1)

comment:1 by Claude Paroz, 11 years ago

Description: modified (diff)

Description reformatted, please use preview when posting.

Note: See TracTickets for help on using tickets.
Back to Top