summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-09-17 17:07:04 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-09-22 16:45:03 +0200
commitc981656169ed68154798cbd10492be674ba46ed6 (patch)
treed2182da3c7b978ebbfd57fe6334eca74e15bc74a /ishtar_common/forms.py
parentfa46a3e8b9006892f8b7fa559c61d41b91c430dc (diff)
downloadIshtar-c981656169ed68154798cbd10492be674ba46ed6.tar.bz2
Ishtar-c981656169ed68154798cbd10492be674ba46ed6.zip
✨ document type field - use select2 widget
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 1804e9c7b..f16a3eeb9 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -684,7 +684,7 @@ class FieldType:
"""
def __init__(self, key, model, is_multiple=False, extra_args=None,
- empty_first=True):
+ empty_first=True, help_text=True):
self.key = key
self.model = model
self.is_multiple = is_multiple
@@ -692,6 +692,7 @@ class FieldType:
if self.is_multiple:
empty_first = False
self.empty_first = empty_first
+ self.help_text = help_text
def get_choices(self, initial=None):
args = {"empty_first": self.empty_first, "initial": initial}
@@ -700,6 +701,8 @@ class FieldType:
return self.model.get_types(**args)
def get_help(self):
+ if not self.help_text:
+ return
args = {}
if self.extra_args:
args.update(self.extra_args)
@@ -837,6 +840,8 @@ class IshtarForm(BSForm, forms.Form):
if field.key not in self.fields:
return
self.fields[field.key].choices = field.get_choices()
+ if not getattr(field, "help_text", True):
+ return
self.fields[field.key].help_text = field.get_help()
def _clean_model_field(self, key, model):