[UPDT] HORILLA WIDGETS: Add disable option if widget value does not exist

This commit is contained in:
Horilla
2024-10-14 11:41:36 +05:30
parent 5cf16398a9
commit 7d3e896081
3 changed files with 4 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ from django import forms
from horilla_widgets.widgets.horilla_multi_select_field import HorillaMultiSelectField
forms.Select.option_template_name = "horilla_widgets/select_option.html"
class HorillaForm(forms.Form):
def clean(self) -> Dict[str, Any]:

View File

@@ -0,0 +1 @@
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %}

View File

@@ -0,0 +1 @@
<option value="{{ widget.value|stringformat:'s' }}" {% include "horilla_widgets/attr.html" %} {% if not widget.value %}disabled{% endif %}>{{ widget.label }}{{widget.disable_option}}</option>