diff --git a/src/ARte/core/forms.py b/src/ARte/core/forms.py index 4bdaeeb2..b5d4fd40 100644 --- a/src/ARte/core/forms.py +++ b/src/ARte/core/forms.py @@ -4,6 +4,25 @@ class UploadFileForm(forms.Form): file = forms.ImageField(required=False) +class ListTextWidget(forms.TextInput): + def __init__(self, *args, **kwargs): + super(ListTextWidget, self).__init__(*args, **kwargs) + self._name = 'exhibit-list' + self._list = Exhibit.objects.all().order_by('name') + self.attrs.update({'list':f'list__{self._name}'}) + + def render(self, name, value, attrs=None, renderer=None): + text_html = super(ListTextWidget, self).render(name, value, attrs=attrs) + data_list = f'' + return (text_html + data_list) class ExhibitForm(forms.Form): - exhibit = forms.ModelChoiceField(queryset=Exhibit.objects.all().order_by('name')) \ No newline at end of file + exhibit = forms.CharField(required=True) + + def __init__(self, *args, **kwargs): + super(ExhibitForm, self).__init__(*args, **kwargs) + self.fields['exhibit'].widget = ListTextWidget() + self.fields['exhibit'].label = "" \ No newline at end of file diff --git a/src/ARte/core/jinja2/core/exhibit_select.jinja2 b/src/ARte/core/jinja2/core/exhibit_select.jinja2 index b0270085..22be5ce5 100644 --- a/src/ARte/core/jinja2/core/exhibit_select.jinja2 +++ b/src/ARte/core/jinja2/core/exhibit_select.jinja2 @@ -14,17 +14,9 @@