Code

Opened 3 years ago

Closed 3 years ago

#14884 closed (wontfix)

Visible form <input>s and <textarea> should use the "required" attribute

Reported by: paulc Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Per HTML5, as well as to have the ability to style required fields differently, visible form fields should output with the "required" attribute if they are required, e.g.

<input type="text" name="..." id="..." required>

That may just be a matter of changing the default widget_attrs to return "required" by default and add to that in subclasses, e.g.

class Field(object):
    # ...
    def widget_attrs(self, widget):
        return {'required': 'required'}

It would be even better if there was a way to output just "required", but that would require changes to forms.util.flatatt as far as I can tell.

I'm up to submit a patch if this seems like a good direction, etc.

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by gabrielhurley

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

The problem with this--and all other HTML5 markup-related tickets--is that they won't validate. It has been (and currently is) Django's position that we produce valid XHTML 4 output.

In past discussions (#12488 is a good example, and there are numerous threads on the Django Developers mailing list) the consensus has been that Django needs to add support for controlling the doctype and output markup format. This requires a significant refactoring of how form widgets, et. al. work.

This issue, and many others, are part of that larger umbrella and need to be fixed as a whole rather than as one-offs.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.