Opened 17 years ago
Closed 17 years ago
#4752 closed (fixed)
Allow arbitrary ErrorList class in BaseForm._html_output
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I realised there is no intent to support "clean" webdesign approach with as_div() shortcuts in BaseForm class as per ticket 3286. Too sad I must say...
Anyway I inherited BaseForm to my own Form implementation that produces clean CSS-able <div></div> output, where the only problem remains with error messages being <ul>-list. Attached is a patch that enables passing my own ErrorList implementation with <div/> support to _html_output() and wraps it all up to a completely <div/>-ed Form. Second attachment is shows my DivForm class and accompanying DivErrorList class.
Attachments (4)
Change History (8)
by , 17 years ago
Attachment: | div-form.diff added |
---|
by , 17 years ago
Attachment: | div-forms.py added |
---|
Sample DivForm class implementation with as_div() shortcut method.
comment:1 by , 17 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
I've been thinking that we might need something like this for a while, too. The first patch is almost exactly what I had in mind, although we'll probably use a shorter parameter name in the final commit. Needs a test (in regressiontests/forms/tests.py) and documentation (docs/newforms.txt) to be complete.
Not sure what the second patch is for. You might want to put that in the wiki as an example after the first patch is commited?
by , 17 years ago
Attachment: | div-form.2.diff added |
---|
Patch that adds a parameter to BaseForm.init constructor to allow using arbitrary ErrorList class implementation
comment:2 by , 17 years ago
In the previous comment is attached an improved patch that converts all other ErrorList usages. Works fine with NON_FIELD_ERRORS as well now.
comment:3 by , 17 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
Triage Stage: | Accepted → Ready for checkin |
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch that adds a parameter to _html_output to allow using arbitrary ErrorList class implementation