mirror of
https://github.com/Sudo-JHare/FHIRFLARE-IG-Toolkit.git
synced 2025-06-14 16:19:59 +00:00
42 lines
1.5 KiB
HTML
42 lines
1.5 KiB
HTML
{# app/templates/_form_helpers.html #}
|
|
{% macro render_field(field, label_visible=true) %}
|
|
<div class="form-group mb-3">
|
|
{% if field.type == "BooleanField" %}
|
|
<div class="form-check">
|
|
{{ field(class="form-check-input" + (" is-invalid" if field.errors else ""), **kwargs) }}
|
|
{% if label_visible and field.label %}
|
|
<label class="form-check-label" for="{{ field.id }}">{{ field.label.text }}</label>
|
|
{% endif %}
|
|
{% if field.description %}
|
|
<small class="form-text text-muted">{{ field.description }}</small>
|
|
{% endif %}
|
|
{% if field.errors %}
|
|
<div class="invalid-feedback">
|
|
{% for error in field.errors %}
|
|
{{ error }}<br>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% else %}
|
|
{% if label_visible and field.label %}
|
|
{{ field.label(class="form-label") }}
|
|
{% endif %}
|
|
{% set css_class = 'form-control ' + kwargs.pop('class', '') %}
|
|
{% if field.errors %}
|
|
{% set css_class = css_class + ' is-invalid' %}
|
|
{% endif %}
|
|
{{ field(class=css_class, **kwargs) }}
|
|
{% if field.description %}
|
|
<small class="form-text text-muted">{{ field.description }}</small>
|
|
{% endif %}
|
|
{% if field.errors %}
|
|
<div class="invalid-feedback">
|
|
{% for error in field.errors %}
|
|
{{ error }}<br>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %} |