aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/templates/wiki/forms
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2019-04-12 16:00:03 +0100
committerGravatar Gareth Coles <[email protected]>2019-04-12 16:00:03 +0100
commita0ff872429a0a61239b78ecd9ed80bb3b12bae98 (patch)
tree22a2a351b99d344f6fd378c8ed663a14ee1700dc /pydis_site/templates/wiki/forms
parentMore forms work - Boolean is done! (diff)
Mostly-working model choice stuff
Diffstat (limited to 'pydis_site/templates/wiki/forms')
-rw-r--r--pydis_site/templates/wiki/forms/fields/model_choice.html42
1 files changed, 40 insertions, 2 deletions
diff --git a/pydis_site/templates/wiki/forms/fields/model_choice.html b/pydis_site/templates/wiki/forms/fields/model_choice.html
index f1104b98..c6cd53ab 100644
--- a/pydis_site/templates/wiki/forms/fields/model_choice.html
+++ b/pydis_site/templates/wiki/forms/fields/model_choice.html
@@ -1,8 +1,10 @@
+{% load wiki_extra %}
+
<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}">
<div class="field-label">
{% if field.label %}
<label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
- MODEL CHOICE: {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
+ {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
</label>
{% endif %}
@@ -16,7 +18,43 @@
<div class="field-body">
<div class="field">
<div class="control">
- {{ field }}
+ <div class="select">
+ {% get_field_options field %}
+
+ <select {% if not options %}disabled{% endif %}
+ id="{{ field.auto_id }}"
+ name="{{ field.name }}"
+
+ {% if field.required %}required{% endif %}
+ >
+ {% if options %}
+ {% for group_name, group_choices, group_index in options %}
+ {% if group_name %}
+ <optgroup label="{{ group_name }}">
+ {% endif %}
+ {% for option in group_choices %}
+ <option {% if option.value == field.value %}selected{% endif %}
+ value="{{ option.value|stringformat:'s' }}"
+ >
+ {{ option.label }}
+ </option>
+ {% endfor %}
+ {% if group_name %}
+ </optgroup>
+ {% endif %}
+ {% endfor %}
+ {% else %}
+ <option value="">
+ {% if field.field.empty_label %}
+ {{ field.field.empty_label }}
+ {% else %}
+ N/A
+ {% endif %}
+ </option>
+ {% endif %}
+ </select>
+ </div>
+
</div>
{% if field.errors %}