From c2d60a414e788d3802c01883681480a4cfe7308c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 28 Feb 2018 17:20:57 +0100 Subject: Forms: manage headers definition in code --- ishtar_common/forms.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ishtar_common/forms.py') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 0c8427d9f..c4d6f2026 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -30,6 +30,7 @@ from django.core import validators from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME from django.utils import formats, translation from django.utils.functional import lazy +from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from bootstrap_datepicker.widgets import DatePicker, DATE_FORMAT, DateField @@ -265,8 +266,20 @@ class FieldType(object): return self.model.get_help(**args) +class FormHeader(object): + def __init__(self, label, level=4): + self.label = label + self.level = level + + def render(self): + return mark_safe(u"{label}".format( + label=self.label, level=self.level + )) + + class IshtarForm(forms.Form): TYPES = [] # FieldType list + HEADERS = {} # field key associated to FormHeader instance def __init__(self, *args, **kwargs): super(IshtarForm, self).__init__(*args, **kwargs) -- cgit v1.2.3