Commit 4f5b0a32 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

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
parent 8b11341a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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: