Django

Code

Ticket #4752 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Allow arbitrary ErrorList class in BaseForm._html_output

Reported by: michal@logix.cz Assigned to: nobody
Milestone: Component: Forms
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

div-form.diff (1.2 kB) - added by michal@logix.cz on 07/03/07 08:29:50.
Patch that adds a parameter to _html_output to allow using arbitrary ErrorList? class implementation
div-forms.py (1.2 kB) - added by michal@logix.cz on 07/03/07 08:31:06.
Sample DivForm? class implementation with as_div() shortcut method.
div-form.2.diff (3.4 kB) - added by michal@logix.cz on 07/03/07 09:14:50.
Patch that adds a parameter to BaseForm?.init constructor to allow using arbitrary ErrorList? class implementation
div-form.3.diff (5.2 kB) - added by SmileyChris on 07/04/07 00:07:58.
simpler version with tests and first-pass docs

Change History

07/03/07 08:29:50 changed by michal@logix.cz

  • attachment div-form.diff added.

Patch that adds a parameter to _html_output to allow using arbitrary ErrorList? class implementation

07/03/07 08:31:06 changed by michal@logix.cz

  • attachment div-forms.py added.

Sample DivForm? class implementation with as_div() shortcut method.

07/03/07 08:46:45 changed by mtredinnick

  • needs_better_patch set to 1.
  • has_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • needs_tests set to 1.
  • needs_docs set to 1.

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?

07/03/07 09:14:50 changed by michal@logix.cz

  • attachment div-form.2.diff added.

Patch that adds a parameter to BaseForm?.init constructor to allow using arbitrary ErrorList? class implementation

07/03/07 09:17:15 changed by michal@logix.cz

In the previous comment is attached an improved patch that converts all other ErrorList? usages. Works fine with NON_FIELD_ERRORS as well now.

07/04/07 00:07:58 changed by SmileyChris

  • attachment div-form.3.diff added.

simpler version with tests and first-pass docs

07/04/07 00:08:45 changed by SmileyChris

  • needs_better_patch deleted.
  • stage changed from Accepted to Ready for checkin.
  • needs_tests deleted.
  • needs_docs deleted.

09/13/07 18:09:41 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6142]) Fixed #4752 -- Make default ErrorList? customisable in newforms display. Based on a patch from michal@logix.cz and SmileyChris?.


Add/Change #4752 (Allow arbitrary ErrorList class in BaseForm._html_output)




Change Properties
Action