diff --git a/pinaxcon/proposals/fields.py b/pinaxcon/proposals/fields.py new file mode 100644 index 00000000..07110012 --- /dev/null +++ b/pinaxcon/proposals/fields.py @@ -0,0 +1,26 @@ +from django import forms + + +class HelpTextWidget(forms.Widget): + template_name = "forms/widgets/help_widget.html" + + def __init__(self, *args, text=None, **kwargs): + super().__init__(*args, **kwargs) + self.text = text + + def render(self, name, value, attrs=None, renderer=None): + context = {'text': self.text} + return self._render(self.template_name, context, renderer) + + +class HelpTextField(forms.Field): + def __init__(self, *args, text=None, **kwargs): + super().__init__(self, *args, **kwargs) + self.required = False + + widget = HelpTextWidget(text=text) + widget.is_required = False + self.widget = widget + + def clean(self, value): + return value \ No newline at end of file diff --git a/pinaxcon/templates/forms/widgets/help_widget.html b/pinaxcon/templates/forms/widgets/help_widget.html new file mode 100644 index 00000000..bdf25cb4 --- /dev/null +++ b/pinaxcon/templates/forms/widgets/help_widget.html @@ -0,0 +1,3 @@ +
+

{{ text|safe }}

+
\ No newline at end of file