#29468: Form Field declaration:
-------------------------------------+-------------------------------------
Reporter: Ivan Muller | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: Field Widget html | Triage Stage:
attrs | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ivan Muller):
Maybe that easy hack may help
{{{
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 370f78e..af99d2e 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -55,7 +55,8 @@ class Field:
-
def __init__(self, *, required=True, widget=None, label=None,
initial=None,
help_text='', error_messages=None,
show_hidden_initial=False,
- validators=(), localize=False, disabled=False,
label_suffix=None):
+ validators=(), localize=False, disabled=False,
label_suffix=None,
+ widget_attrs={}):
# required -- Boolean that specifies whether the field is
required.
# True by default.
# widget -- A Widget class, or instance of a Widget class, that
should
@@ -100,6 +101,7 @@ class Field:
-
# Hook into self.widget_attrs() for any Field-specific HTML
attributes.
extra_attrs = self.widget_attrs(widget)
+ extra_attrs.update(widget_attrs)
if extra_attrs:
widget.attrs.update(extra_attrs)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29468#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/068.4671365c0f897ee4a95f3873955fb740%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.