summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_context_records/forms.py5
-rw-r--r--ishtar_common/widgets.py11
2 files changed, 13 insertions, 3 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index a65aad717..42c76a9ad 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -912,8 +912,9 @@ class QADating(ManageOldType, forms.Form):
label=_("Reference"), validators=[validators.MaxLengthValidator(400)],
required=False
)
- period_id = forms.ChoiceField(label=_("Chronological period"), choices=[],
- required=False)
+ period_id = widgets.Select2SimpleField(
+ label=_("Period"), required=False, modal="modal-dynamic-form"
+ )
start_date = forms.IntegerField(label=_("Start date"), required=False)
end_date = forms.IntegerField(label=_("End date"), required=False)
quality_id = forms.ChoiceField(label=_("Quality"), required=False, choices=[])
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index 85a1d20b1..d4c9d625d 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -311,6 +311,13 @@ class Select2Base(Select2Media):
except (self.model.DoesNotExist, ValueError):
# an old reference? it should not happen
pass
+ if attrs.get("modal", None):
+ if options:
+ options = options[:-1] + ", "
+ else:
+ options = "{"
+ modal = attrs['modal']
+ options += f" dropdownParent: $('#{modal}')}}"
if attrs.get("full-width", None):
if options:
options = options[:-1] + ", "
@@ -401,6 +408,8 @@ class Select2BaseField(object):
widget = Select2Multiple
else:
widget = Select2Simple
+ if "modal" in kwargs:
+ attrs["modal"] = kwargs.pop("modal")
if kwargs.get("style", None):
attrs["style"] = kwargs.pop("style")
kwargs["widget"] = widget(
@@ -410,7 +419,7 @@ class Select2BaseField(object):
new=new,
attrs=attrs,
)
- super(Select2BaseField, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def get_q(self):
q = self.model.objects