diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-10-28 14:24:18 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-10-28 14:24:18 +0100 | 
| commit | cba11779565c9c258388a61c90e760210b92fcaa (patch) | |
| tree | 66d8a50a4c022bee5c5644e3cb2385f9c2f38717 /ishtar_common/wizards.py | |
| parent | 5bac47e9b5ac37235d7bf282b13f6855c793a86f (diff) | |
| download | Ishtar-cba11779565c9c258388a61c90e760210b92fcaa.tar.bz2 Ishtar-cba11779565c9c258388a61c90e760210b92fcaa.zip  | |
Add autofocus to first field of wizard pages (refs #1463)
Diffstat (limited to 'ishtar_common/wizards.py')
| -rw-r--r-- | ishtar_common/wizards.py | 11 | 
1 files changed, 11 insertions, 0 deletions
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):  | 
