Opened 18 years ago

Closed 17 years ago

#3568 closed (wontfix)

Add support for serializing newforms to HTML

Reported by: Benjamin Hawkes-Lewis <bhawkeslewis@…> Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: newforms html xhtml
Cc: treborhudson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Currently, newforms only serializes to suit W3C's often-criticized Guidelines for serving XHTML 1.0 as text/html to buggy user agents. Its markup is not conformant with the HTML 4.01 specification, because according to HTML's SGML definition <input /> means <input>&gt; not <input>. My patch leaves the status quo as the default, but facilitates producing conformant HTML by adding an optional argument to the serialization methods. as_p(forms.SERIALIZATION_HTML401) for example. If there's a better way to achieve the same thing, that would be good too. It would also be nice to be able to set SERIALIZATION_DEFAULT app-wide, but I'm not sure how that's done. It may be that an end_empty_element() function would be useful elsewhere in Django too.

Attachments (2)

htmlnewforms.diff (15.6 KB ) - added by Benjamin Hawkes-Lewis <bhawkeslewis@…> 18 years ago.
htmlnewforms.2.diff (16.4 KB ) - added by Benjamin Hawkes-Lewis <bhawkeslewis@…> 18 years ago.
A couple fixes to my patch

Download all attachments as: .zip

Change History (7)

by Benjamin Hawkes-Lewis <bhawkeslewis@…>, 18 years ago

Attachment: htmlnewforms.diff added

by Benjamin Hawkes-Lewis <bhawkeslewis@…>, 18 years ago

Attachment: htmlnewforms.2.diff added

A couple fixes to my patch

comment:1 by Simon G. <dev@…>, 18 years ago

Component: Core frameworkdjango.newforms
Triage Stage: UnreviewedDesign decision needed

comment:2 by Chris Beaven, 18 years ago

Patch needs improvement: set

Benjamin - you need to add your serializations package to SVN and create a new patch.

comment:3 by Armin Ronacher, 17 years ago

A big +1 for that. I would love to see HTML compatible forms in django.

comment:4 by treborhudson@…, 17 years ago

Cc: treborhudson@… added

Yes! Please! I avoid newforms b/c it outputs XHTML. It's trivial and anal, I know, but for us who think XHTML is "broken", please include this in Django!

comment:5 by Jacob, 17 years ago

Resolution: wontfix
Status: newclosed

We can't possibly include all the myriad ways someone might want to represent a form (XForms, anyone?). The as_* methods are shortcuts; nothing more. I'd consider an approach using a template filter here (i.e. {{ form|to_html }}).

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