mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
newforms-admin: Moved first_form_field_id calculation from render_change_form() to AdminForm()
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4375 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4e98d69be6
commit
1fc252e087
@ -76,6 +76,10 @@ class AdminForm(object):
|
||||
for fieldset in self.fieldsets:
|
||||
yield BoundFieldset(self.form, fieldset)
|
||||
|
||||
def first_field(self):
|
||||
for bf in self.form:
|
||||
return bf
|
||||
|
||||
class Fieldset(object):
|
||||
def __init__(self, name=None, fields=(), classes=(), description=None):
|
||||
self.name, self.fields = name, fields
|
||||
|
@ -24,5 +24,7 @@
|
||||
<p class="help">{% trans 'Enter the same password as above, for verification.' %}</p>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">document.getElementById("id_username").focus();</script>
|
||||
|
||||
</fieldset>
|
||||
{% endblock %}
|
||||
|
@ -46,7 +46,7 @@
|
||||
<input type="submit" value="{% trans 'Change password' %}" class="default" />
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">document.getElementById("{{ first_form_field_id }}").focus();</script>
|
||||
<script type="text/javascript">document.getElementById("id_password1").focus();</script>
|
||||
</div>
|
||||
</form></div>
|
||||
{% endblock %}
|
||||
|
@ -79,7 +79,7 @@
|
||||
{% submit_row %}
|
||||
|
||||
{% if add %}
|
||||
<script type="text/javascript">document.getElementById("{{ first_form_field_id }}").focus();</script>
|
||||
<script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
|
||||
{% endif %}
|
||||
|
||||
{% if auto_populated_fields %}
|
||||
|
@ -38,7 +38,6 @@ def user_add_stage(request):
|
||||
'has_absolute_url': False,
|
||||
'auto_populated_fields': (),
|
||||
'bound_field_sets': (),
|
||||
'first_form_field_id': 'id_username',
|
||||
'opts': User._meta,
|
||||
'username_help_text': User._meta.get_field('username').help_text,
|
||||
}, context_instance=template.RequestContext(request))
|
||||
@ -69,7 +68,6 @@ def user_change_password(request, id):
|
||||
'has_delete_permission': False,
|
||||
'has_change_permission': True,
|
||||
'has_absolute_url': False,
|
||||
'first_form_field_id': 'id_password1',
|
||||
'opts': User._meta,
|
||||
'original': user,
|
||||
'show_save': True,
|
||||
|
@ -173,7 +173,6 @@ def render_change_form(model_admin, model, manipulator, context, add=False, chan
|
||||
field_sets = model_admin.get_field_sets()
|
||||
original = getattr(manipulator, 'original_object', None)
|
||||
bound_field_sets = [field_set.bind(context['oldform'], original, AdminBoundFieldSet) for field_set in field_sets]
|
||||
first_form_field_id = bound_field_sets[0].bound_field_lines[0].bound_fields[0].form_fields[0].get_id();
|
||||
ordered_objects = opts.get_ordered_objects()
|
||||
inline_related_objects = opts.get_followed_related_objects(manipulator.follow)
|
||||
extra_context = {
|
||||
@ -185,7 +184,6 @@ def render_change_form(model_admin, model, manipulator, context, add=False, chan
|
||||
'has_absolute_url': hasattr(model, 'get_absolute_url'),
|
||||
'auto_populated_fields': auto_populated_fields,
|
||||
'bound_field_sets': bound_field_sets,
|
||||
'first_form_field_id': first_form_field_id,
|
||||
'javascript_imports': get_javascript_imports(opts, auto_populated_fields, field_sets),
|
||||
'ordered_objects': ordered_objects,
|
||||
'inline_related_objects': inline_related_objects,
|
||||
|
Loading…
x
Reference in New Issue
Block a user