﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14364	Admin add form, element focus script not working because of wrong id	Wouter van der Graaf	nobody	"I get a JavaScript error for this line in the change_form.html template:
{{{
{% if adminform and add %}
   <script type=""text/javascript"">document.getElementById(""{{ adminform.first_field.auto_id }}"").focus();</script>
{% endif %}
}}}
That's because the first field in the form is the default date/time widget, consisting of 2 input fields. The referred id is not used in this widget.

Quick and dirty fix: check if element with id exists:
{{{
{% if adminform and add %}
   <script type=""text/javascript"">var focusEl = document.getElementById(""{{ adminform.first_field.auto_id }}""); if (focusEl && focusEl.focus) { focusEl.focus(); }</script>
{% endif %}
}}}
"		closed	contrib.admin	1.2		invalid	add_form		Unreviewed	1	0	0	0	0	0
