diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-08 12:23:23 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-08 12:23:23 +0000 |
| commit | 27e7fcbab015452cb4201f32eb2682bd8dc23feb (patch) | |
| tree | f5fb8b300a2f8b0058e7d0702ec5e69be799c3db /django/forms/forms.py | |
| parent | 09a820550b0d4bff9fc4fd641a1d6707b3cc0c85 (diff) | |
[1.2.X] Fixed #10573 -- Corrected autofocus problem in admin when the first widget displayed is a multiwidget. Thanks to rduffield for the report, and to Ramiro and Julien Phalip for the patch.
Backport of r15452 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15456 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/forms.py')
| -rw-r--r-- | django/forms/forms.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index 46e97ef5b9..b520d7e32e 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -518,3 +518,14 @@ class BoundField(StrAndUnicode): return self.html_name return '' auto_id = property(_auto_id) + + def _id_for_label(self): + """ + Wrapper around the field widget's `id_for_label` class method. + Useful, for example, for focusing on this field regardless of whether + it has a single widget or a MutiWidget. + """ + widget = self.field.widget + id_ = widget.attrs.get('id') or self.auto_id + return widget.id_for_label(id_) + id_for_label = property(_id_for_label) |
