From 9d1af62e6177c8e9f11ebde86f3894f1e111f4d7 Mon Sep 17 00:00:00 2001 From: Horilla Date: Mon, 18 Nov 2024 13:52:30 +0530 Subject: [PATCH] [UPDT] HORILLA VIEWS: Empty option not selectable to selectable in HLV bulk update --- horilla_views/forms.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/horilla_views/forms.py b/horilla_views/forms.py index 113ab1ffe..9d8897346 100644 --- a/horilla_views/forms.py +++ b/horilla_views/forms.py @@ -128,23 +128,34 @@ class DynamicBulkUpdateForm(forms.Form): label=val.verbose_name.capitalize(), required=False, ) + self.fields[key].widget.option_template_name = ( + "horilla_widgets/select_option.html", + ) continue elif not getattribute(val, "related_model"): if isinstance(val, models.models.CharField) and val.choices: self.fields[key] = forms.ChoiceField( - choices=val.choices, + choices=[("", "--------")] + + [choice for choice in val.choices if choice[0] != ""], widget=forms.Select( attrs={"class": "oh-select oh-select-2 w-100"} ), label=val.verbose_name.capitalize(), required=False, ) + self.fields[key].widget.option_template_name = ( + "horilla_widgets/select_option.html", + ) + print(self.fields[key].empty_values) continue self.fields[key] = field( widget=widget, label=val.verbose_name.capitalize(), required=False, ) + self.fields[key].widget.option_template_name = ( + "horilla_widgets/select_option.html", + ) continue queryset = val.related_model.objects.all() self.fields[key] = field( @@ -153,6 +164,9 @@ class DynamicBulkUpdateForm(forms.Form): label=val.verbose_name, required=False, ) + self.fields[key].widget.option_template_name = ( + "horilla_widgets/select_option.html", + ) def save(self, *args, **kwargs): """