diff -r 24c4a0011078 -r 4c60652a3947 app/soc/views/helper/forms.py --- a/app/soc/views/helper/forms.py Sun Oct 19 21:08:08 2008 +0000 +++ b/app/soc/views/helper/forms.py Sun Oct 19 21:12:08 2008 +0000 @@ -74,6 +74,38 @@ self.fields[field_name].help_text = model_prop.help_text +class BaseForm(DbModelForm): + """Subclass of DbModelForm that extends as_table HTML output. + + BaseForm has additional class names in HTML tags for label and help text + and those can be used in CSS files for look customization. The way the Form + prints itself also has changed. Help text is displayed in the same row as + label and input. + """ + # TODO(pawel.solyga): Add class names for form errors and required fields. + + DEF_NORMAL_ROW = u'%(label)s' \ + '%(errors)s%(field)s%(help_text)s' + DEF_ERROR_ROW = u'%s' + DEF_ROW_ENDER = '' + DEF_HELP_TEXT_HTML = u'%s' + + def __init__(self, *args, **kwargs): + """Parent class initialization. + + Args: + *args, **kwargs: passed through to parent __init__() constructor + """ + super(BaseForm, self).__init__(*args, **kwargs) + + def as_table(self): + """Returns form rendered as HTML rows -- with no
.""" + return self._html_output(self.DEF_NORMAL_ROW, + self.DEF_ERROR_ROW, + self.DEF_ROW_ENDER, + self.DEF_HELP_TEXT_HTML, False) + + class SelectQueryArgForm(forms.Form): """URL query argument change control implemented as a Django form. """