Opened 14 years ago

Closed 14 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: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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.

Change History (1)

comment:1 by Gabriel Hurley, 14 years ago

Resolution: wontfix
Status: newclosed

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.

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