Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#12488 closed (wontfix)

Add EmailInput and URLInput widgets

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

Description

As there is now a special HTML(5) email input type, I propose that there should be an EmailInput widget as a part of Django. As documented here, it degrades gracefully in all browsers, so there is little reason not to use it. I understand that Django typically has supported HTML4/XHTML, so perhaps it should not be the default widget for the EmailField, but the attached patch has it this way should anyone think it should be (I, for one, would be for this but I realize that it could invalidate some people's existing templates).

Attachments (2)

email_input.diff (1.9 KB) - added by Oliver Beattie 7 years ago.
email_url_inputs.diff (2.3 KB) - added by Oliver Beattie 7 years ago.

Download all attachments as: .zip

Change History (10)

Changed 7 years ago by Oliver Beattie

Attachment: email_input.diff added

comment:1 Changed 7 years ago by Oliver Beattie

Summary: Add an `EmailInput` to `django.forms.widgets`Add `EmailInput` and `URLInput` widgets

On second thought, the new <input type="url"> would be equally worthy of supporting here. I've attached a different patch. Of note is that on the iPhone, the visual keyboard layout is changed into an email-specific or URL-specific variant for the respective input types, so there is a real benefit to users of having this.

Changed 7 years ago by Oliver Beattie

Attachment: email_url_inputs.diff added

comment:2 Changed 7 years ago by Oliver Beattie

Summary: Add `EmailInput` and `URLInput` widgetsAdd EmailInput and URLInput widgets

comment:3 Changed 7 years ago by Oliver Beattie

Jeez, am I failsome today. The "here" I refer to in the ticket description ("As documented here, it degrades gracefully in all browsers") is a reference to this page.

comment:4 Changed 7 years ago by Luke Plant

Resolution: wontfix
Status: newclosed

The validation issue is a big one, unfortunately. At the moment, we can't have this as a default, which brings into question the usefulness of having this in Django at all. We normally ship components that work well together, and this one does not work well with the templates that ship with Django.

This brings up the bigger question of how to support the different dialects of HTML. In some ways, HTML5 could help us out here, as it supports both XHTML 'style' and HTML 'style' tags under the same DOCTYPE. But there are problems with adopting HTML5 at this point - like the backwards compatibility promise we have, which means we can't just go changing doctypes, and the fact that the spec isn't done and the lack of validator tools for it.

So, I'm closing WONTFIX, as we are not supporting HTML5 at this time.

comment:5 Changed 7 years ago by Alex Gaynor

It's probably worth noting that all browsers (dating back as far as IE6) degrade gracefully to input type="text" for email and url.

comment:6 Changed 6 years ago by Patryk Zawadzki

lukeplant:

Could you elaborate more on why you believe it breaks backwards compatibility? The fields degrade in all browsers. They produce both valid XML and valid HTML. The only thing that might change is the output of the W3C validator for non-HTML5 documents. And changing the DOCTYPE to "html" is a mere annoyance comparable to changing "maxlength" to "max_length" in model definitions.

comment:7 Changed 6 years ago by Russell Keith-Magee

patrys: Having <input type="url" > may degrade, but it doesn't validate. On top of that, Django's output rendering follows XHTML conventions; introducing rendering elements drawn from HTML5 starts to confuse matters.

That said, adding support for HTML5 is on my radar personally, along with a number of other form-rendering related improvements. Check the django-dev mailing list for recent discussions. I'm hoping to be able to sprint on this a little bit at DjangoCon.

comment:8 Changed 6 years ago by Patryk Zawadzki

Just to be clear: HTML5 allows XML style tags. There is also no loss when changing the doctype to plain "html".

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