Skip to content

Commit

Permalink
fix(example/templates): Render select field properly
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Dec 12, 2024
1 parent 3a7bba4 commit 1eac57c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</div>
{% elif attrs.type == "textarea" %}
<div class="mb-3">
<label class="" for="{{ attrs.id }}">
<label for="{{ attrs.id }}">
{% slot label %}
{% endslot %}
</label>
Expand All @@ -39,10 +39,31 @@
id="{{ attrs.id }}"
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %}
type="hidden">
{% elif attrs.type == "select" %}
<div class="{% if attrs.unlabeled %}form-floating{% endif %} mb-3">
{% if not attrs.unlabeled %}
<label for="{{ attrs.id }}">
{% slot label %}
{% endslot %}
</label>
{% endif %}
<select id="{{ attrs.id }}" name="{{ attrs.name }}" class="form-select">
{% for option in attrs.choices %}
<option {% if option.0 == attrs.value %}selected{% endif %}
value="{{ option.0 }}">{{ option.1 }}</option>
{% endfor %}
</select>
{% if attrs.unlabeled %}
<label for="{{ attrs.id }}">
{% slot label %}
{% endslot %}
</label>
{% endif %}
</div>
{% else %}
<div class="{% if attrs.unlabeled %}form-floating{% endif %} mb-3">
{% if not attrs.unlabeled %}
<label class="" for="{{ attrs.id }}">
<label for="{{ attrs.id }}">
{% slot label %}
{% endslot %}
</label>
Expand All @@ -60,7 +81,7 @@
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %}
type="{{ attrs.type }}">
{% if attrs.unlabeled %}
<label class="" for="{{ attrs.id }}">
<label for="{{ attrs.id }}">
{% slot label %}
{% endslot %}
</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load allauth %}
{% for bound_field in attrs.form %}
{% 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 %}
{% 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 %}
{% slot label %}
{{ bound_field.label }}
{% endslot %}
Expand Down

0 comments on commit 1eac57c

Please sign in to comment.