#26234: Add `css_classes` parameter to Form.as_*() methods
------------------------------+--------------------------------------
Reporter: willstott101 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Resolution:
Keywords: css forms | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Comment (by willstott101):
I understand why you're concerned. I would justify this by saying that the
patch only modifies the actual tag specified in the method name. As the
method is already a direct reference to that html tag, any customisation
would be logically kept to the tag which that function adds (surely
'''never''' more than `attrs={}`).
I also don't see many situations where additional parameters would get
passed into the Field.css_classes method. As it would surely be only
called in:
* a template (where you would just `class="{{field.css_classes}} myclass"`
anyway)
* this `Form._html_output` method
* or something very similar and unnecessary to write.
I just feel the .as_* methods are almost useless without ''some''
customisation. And it feels natural for me to do `form.as_p('large')` or
the like with that method.
Your particular snippet adds classes to the ''widget'', not the form
container (i.e. also encompassing the <label>).
But I get where you're coming from. And I've used a more granual(?) form
template to get around this, which was simpler than I expected (but brings
up the "what's the point" in the methods if they can't be adjusted
argument again).
--
Ticket URL: <https://code.djangoproject.com/ticket/26234#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.c6be4f14b68e442fff74ca6c0a2f2a66%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.