Ticket #10573: admin.diff
File admin.diff, 1.5 KB (added by , 16 years ago) |
---|
-
django/forms/forms.py
10 10 from django.utils.safestring import mark_safe 11 11 12 12 from fields import Field, FileField 13 from widgets import Media, media_property, TextInput, Textarea 13 from widgets import Media, media_property, TextInput, Textarea, MultiWidget 14 14 from util import flatatt, ErrorDict, ErrorList, ValidationError 15 15 16 16 __all__ = ('BaseForm', 'Form') … … 434 434 return self.html_name 435 435 return '' 436 436 auto_id = property(_auto_id) 437 438 def _focus_id(self): 439 """ 440 Returns the correct field to auto-focus on when rendering the form. 441 """ 442 if isinstance(self.field.widget, MultiWidget): 443 return '%s_0' % self.auto_id 444 else: 445 return self.auto_id 446 focus_id = property(_focus_id) -
django/contrib/admin/templates/admin/change_form.html
55 55 {% submit_row %} 56 56 57 57 {% if add %} 58 <script type="text/javascript">document.getElementById("{{ adminform.first_field. auto_id }}").focus();</script>58 <script type="text/javascript">document.getElementById("{{ adminform.first_field.focus_id }}").focus();</script> 59 59 {% endif %} 60 60 61 61 {# JavaScript for prepopulated fields #}