From 01d3cdaacabcdca55bd08d67df5339ea5bfa92d7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 26 May 2014 16:01:20 +0200 Subject: Put autofocus on first field of tableform (refs #1596) --- ishtar_common/forms.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ishtar_common') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 9c81fa04b..88a3306f4 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2013 Étienne Loks +# Copyright (C) 2010-2014 Étienne Loks # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -105,6 +105,11 @@ class FormSet(BaseFormSet): form.fields[DELETION_FIELD_NAME].widget = widgets.DeleteWidget() class TableSelect(forms.Form): + def __init__(self, *args, **kwargs): + super(TableSelect, self).__init__(*args, **kwargs) + key = self.fields.keyOrder[0] + self.fields[key].widget.attrs['autofocus'] = 'autofocus' + def get_input_ids(self): return self.fields.keys() -- cgit v1.2.3