Skip to content

Commit 1eac57c

Browse files
committed
fix(example/templates): Render select field properly
1 parent 3a7bba4 commit 1eac57c

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

examples/regular-django/example/templates/allauth/elements/field.html

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</div>
2222
{% elif attrs.type == "textarea" %}
2323
<div class="mb-3">
24-
<label class="" for="{{ attrs.id }}">
24+
<label for="{{ attrs.id }}">
2525
{% slot label %}
2626
{% endslot %}
2727
</label>
@@ -39,10 +39,31 @@
3939
id="{{ attrs.id }}"
4040
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %}
4141
type="hidden">
42+
{% elif attrs.type == "select" %}
43+
<div class="{% if attrs.unlabeled %}form-floating{% endif %} mb-3">
44+
{% if not attrs.unlabeled %}
45+
<label for="{{ attrs.id }}">
46+
{% slot label %}
47+
{% endslot %}
48+
</label>
49+
{% endif %}
50+
<select id="{{ attrs.id }}" name="{{ attrs.name }}" class="form-select">
51+
{% for option in attrs.choices %}
52+
<option {% if option.0 == attrs.value %}selected{% endif %}
53+
value="{{ option.0 }}">{{ option.1 }}</option>
54+
{% endfor %}
55+
</select>
56+
{% if attrs.unlabeled %}
57+
<label for="{{ attrs.id }}">
58+
{% slot label %}
59+
{% endslot %}
60+
</label>
61+
{% endif %}
62+
</div>
4263
{% else %}
4364
<div class="{% if attrs.unlabeled %}form-floating{% endif %} mb-3">
4465
{% if not attrs.unlabeled %}
45-
<label class="" for="{{ attrs.id }}">
66+
<label for="{{ attrs.id }}">
4667
{% slot label %}
4768
{% endslot %}
4869
</label>
@@ -60,7 +81,7 @@
6081
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %}
6182
type="{{ attrs.type }}">
6283
{% if attrs.unlabeled %}
63-
<label class="" for="{{ attrs.id }}">
84+
<label for="{{ attrs.id }}">
6485
{% slot label %}
6586
{% endslot %}
6687
</label>

examples/regular-django/example/templates/allauth/elements/fields.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load allauth %}
22
{% for bound_field in attrs.form %}
3-
{% element field unlabeled=attrs.unlabeled name=bound_field.name type=bound_field.field.widget.input_type required=bound_field.field.required value=bound_field.value id=bound_field.auto_id errors=bound_field.errors placeholder=bound_field.field.widget.attrs.placeholder tabindex=bound_field.field.widget.attrs.tabindex autocomplete=bound_field.field.widget.attrs.autocomplete style=bound_field.field.widget.attrs.style %}
3+
{% element field unlabeled=attrs.unlabeled name=bound_field.name type=bound_field.field.widget.input_type required=bound_field.field.required value=bound_field.value id=bound_field.auto_id errors=bound_field.errors placeholder=bound_field.field.widget.attrs.placeholder tabindex=bound_field.field.widget.attrs.tabindex autocomplete=bound_field.field.widget.attrs.autocomplete style=bound_field.field.widget.attrs.style choices=bound_field.field.choices %}
44
{% slot label %}
55
{{ bound_field.label }}
66
{% endslot %}

0 commit comments

Comments
 (0)