Files
CTFd/templates/macros/forms.html
Kevin Chung a64e7d51ef Squashed 'CTFd/themes/core-beta/' changes from 9126d77d..5ce3003b
5ce3003b Merge pull request #47 from aCursedComrade/patch-1
c9887cb1 Fix team template

git-subtree-dir: CTFd/themes/core-beta
git-subtree-split: 5ce3003b4d68352e629ee2d390bc999e7d6b071e
2023-06-11 15:56:28 -04:00

60 lines
1.6 KiB
HTML

{% macro render_extra_fields(fields, show_labels=True, show_optionals=True, show_descriptions=True) -%}
{% for field in fields %}
{% if field.field_type == "text" %}
<div class="mb-3">
{% if show_labels %}
<b>{{ field.label(class="form-label") }}</b>
{% endif %}
{% if show_optionals %}
{% if field.flags.required is false %}
<small class="ms-1 text-muted">
{% trans %}(Optional){% endtrans %}
</small>
{% endif %}
{% endif %}
{{ field(class="form-control") }}
{% if show_descriptions %}
{% if field.description %}
<small class="form-text text-muted">
{{ field.description }}
</small>
{% endif %}
{% endif %}
</div>
{% elif field.field_type == "boolean" %}
<div>
{{ field.label(class="form-label") }}
{% if show_optionals %}
{% if field.flags.required is false %}
<small class="ms-1 text-muted">
{% trans %}(Optional){% endtrans %}
</small>
{% endif %}
{% endif %}
</div>
<div class="mb-3 border border-1 p-3">
<div class="form-check">
{{ field(class="form-check-input") }}
{{ field.label(class="form-check-label") }}
</div>
{% if show_descriptions %}
{% if field.description %}
<small class="form-text text-muted">
{{ field.description }}
</small>
{% endif %}
{% endif %}
</div>
{% endif %}
{% endfor %}
{%- endmacro %}