| 1 |
{% load allauth %} |
| 2 |
{% if attrs.type == "checkbox" or attrs.type == "radio" %} |
| 3 |
<div class="form-check mb-3"> |
| 4 |
<input {% if attrs.required %}required{% endif %} |
| 5 |
name="{{ attrs.name }}" |
| 6 |
class="form-check-input" |
| 7 |
id="{{ attrs.id }}" |
| 8 |
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %} |
| 9 |
{% if attrs.disabled %}disabled{% endif %} |
| 10 |
type="{{ attrs.type }}"> |
| 11 |
<label class="form-check-label" for="{{ attrs.id }}"> |
| 12 |
{% slot label %} |
| 13 |
{% endslot %} |
| 14 |
</label> |
| 15 |
{% if slots.help_text %} |
| 16 |
<div class="form-text"> |
| 17 |
{% slot help_text %} |
| 18 |
{% endslot %} |
| 19 |
</div> |
| 20 |
{% endif %} |
| 21 |
</div> |
| 22 |
{% elif attrs.type == "textarea" %} |
| 23 |
<div class="mb-3"> |
| 24 |
<label for="{{ attrs.id }}"> |
| 25 |
{% slot label %} |
| 26 |
{% endslot %} |
| 27 |
</label> |
| 28 |
<textarea {% if attrs.required %}required{% endif %} |
| 29 |
{% if attrs.rows %}rows="{{ attrs.rows }}"{% endif %} |
| 30 |
class="form-control" |
| 31 |
name="{{ attrs.name }}" |
| 32 |
{% if attrs.readonly %}readonly{% endif %} |
| 33 |
id="{{ attrs.id }}" |
| 34 |
{% if attrs.disabled %}disabled{% endif %}>{% slot value %}{% endslot %}</textarea> |
| 35 |
</div> |
| 36 |
{% elif attrs.type == "hidden" %} |
| 37 |
<input {% if attrs.required %}required{% endif %} |
| 38 |
name="{{ attrs.name }}" |
| 39 |
id="{{ attrs.id }}" |
| 40 |
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %} |
| 41 |
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> |
| 63 |
{% else %} |
| 64 |
<div class="{% if attrs.unlabeled %}form-floating{% endif %} mb-3"> |
| 65 |
{% if not attrs.unlabeled %} |
| 66 |
<label for="{{ attrs.id }}"> |
| 67 |
{% slot label %} |
| 68 |
{% endslot %} |
| 69 |
</label> |
| 70 |
{% endif %} |
| 71 |
<input {% if attrs.required %}required{% endif %} |
| 72 |
name="{{ attrs.name }}" |
| 73 |
{% if attrs.placeholder %}placeholder="{{ attrs.placeholder }}" {% elif attrs.unlabeled %}placeholder="{% slot label %}{% endslot %}"{% endif %} |
| 74 |
class="{% if attrs.errors %}is-invalid{% endif %} form-control rounded-3" |
| 75 |
id="{{ attrs.id }}" |
| 76 |
{% if attrs.readonly %}readonly{% endif %} |
| 77 |
{% if attrs.disabled %}disabled{% endif %} |
| 78 |
{% if attrs.tabindex %}tabindex="{{ attrs.tabindex }}"{% endif %} |
| 79 |
{% if attrs.style %}style="{{ attrs.style }}"{% endif %} |
| 80 |
{% if attrs.autocomplete %}autocomplete="{{ attrs.autocomplete }}"{% endif %} |
| 81 |
{% if attrs.value is not None %}value="{{ attrs.value }}"{% endif %} |
| 82 |
type="{{ attrs.type }}"> |
| 83 |
{% if attrs.unlabeled %} |
| 84 |
<label for="{{ attrs.id }}"> |
| 85 |
{% slot label %} |
| 86 |
{% endslot %} |
| 87 |
</label> |
| 88 |
{% endif %} |
| 89 |
{% if slots.help_text %} |
| 90 |
<div class="form-text"> |
| 91 |
{% slot help_text %} |
| 92 |
{% endslot %} |
| 93 |
</div> |
| 94 |
{% endif %} |
| 95 |
{% if attrs.errors %} |
| 96 |
{% for error in attrs.errors %}<div role="alert" class="invalid-feedback">{{ error }}</div>{% endfor %} |
| 97 |
{% endif %} |
| 98 |
</div> |
| 99 |
{% endif %} |