Kaydet (Commit) 4f5b0a32 authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

Fixed #8194 (again): correctly focus on the first declared field in the admin.…

Fixed #8194 (again): correctly focus on the first declared field in the admin. Thanks to fredbartle for catching my silly mistake the first time 'round.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 8b11341a
......@@ -20,9 +20,14 @@ class AdminForm(object):
yield Fieldset(self.form, name, **options)
def first_field(self):
if self.form._meta.fields is not None:
name = self.form._meta.fields[0]
return forms.BoundField(self.form, self.form.fields[name], name)
try:
fieldset_name, fieldset_options = self.fieldsets[0]
field_name = fieldset_options['fields'][0]
if not isinstance(field_name, basestring):
field_name = field_name[0]
return self.form[field_name]
except (KeyError, IndexError):
pass
try:
return iter(self.form).next()
except StopIteration:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment