From 9a33d0958d9cda16b8e0f2e3ce8191c6749e0b36 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 28 Oct 2013 14:24:18 +0100 Subject: Add autofocus to first field of wizard pages (refs #1463) --- ishtar_common/wizards.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 89f005a0a..f27a2bd55 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -509,6 +509,17 @@ class Wizard(NamedUrlWizardView): # init[0][k] data = data or None form = super(Wizard, self).get_form(step, data, files) + # add autofocus to first field + frm = None + if hasattr(form, 'fields') and form.fields.keys(): + frm = form + elif hasattr(form, 'forms') and form.forms and form.forms[0].fields.keys(): + frm = form.forms[0] + if frm: + first_field = frm.fields[frm.fields.keyOrder[0]] + attrs = first_field.widget.attrs + attrs.update({'autofocus':"autofocus"}) + first_field.widget.attrs = attrs return form def render_next_step(self, form, **kwargs): -- cgit v1.2.3