2016-03-01 11:23:03 -05:00
|
|
|
{% load form_helpers %}
|
2021-03-15 07:49:59 -07:00
|
|
|
{% load helpers %}
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
<div class="row mb-3{% if field.errors %} has-errors{% endif %}">
|
2021-03-13 02:19:42 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
{# Render the field label, except for: #}
|
|
|
|
{# 1. Checkboxes (label appears to the right of the field #}
|
|
|
|
{# 2. Textareas with no label set (will expand across entire row) #}
|
2023-03-20 13:14:11 -04:00
|
|
|
{% if label and not field|widget_type == 'checkboxinput' %}
|
2022-11-22 12:02:21 -05:00
|
|
|
<label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label text-lg-end{% if field.field.required %} required{% endif %}">
|
|
|
|
{{ label }}
|
|
|
|
</label>
|
|
|
|
{% endif %}
|
2021-03-13 02:19:42 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
{# Render the field itself #}
|
|
|
|
<div class="col{% if field|widget_type == 'checkboxinput' %} offset-3{% endif %}">
|
|
|
|
{# Include the "regenerate" button on slug fields #}
|
|
|
|
{% if field|widget_type == 'slugwidget' %}
|
|
|
|
<div class="input-group">
|
|
|
|
{{ field }}
|
|
|
|
<button id="reslug" type="button" title="Regenerate Slug" class="btn btn-outline-dark border-input">
|
|
|
|
<i class="mdi mdi-reload"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
{# Render checkbox labels to the right of the field #}
|
|
|
|
{% elif field|widget_type == 'checkboxinput' %}
|
|
|
|
<div class="form-check">
|
|
|
|
{{ field }}
|
|
|
|
<label for="{{ field.id_for_label }}" class="form-check-label">
|
|
|
|
{{ label }}
|
2021-07-20 00:16:13 -07:00
|
|
|
</label>
|
2022-11-22 12:02:21 -05:00
|
|
|
</div>
|
|
|
|
{# Default field rendering #}
|
|
|
|
{% else %}
|
|
|
|
{{ field }}
|
|
|
|
{% endif %}
|
2021-03-13 02:19:42 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
{# Display any error messages #}
|
|
|
|
{% if field.errors %}
|
|
|
|
<div class="form-text text-danger">
|
|
|
|
{% for error in field.errors %}{{ error }}{% if not forloop.last %}<br />{% endif %}{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% elif field.field.required %}
|
|
|
|
<div class="invalid-feedback">
|
|
|
|
This field is required.
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-09-02 16:48:54 -04:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
{# Help text #}
|
|
|
|
{% if field.help_text %}
|
|
|
|
<span class="form-text">{{ field.help_text|safe }}</span>
|
|
|
|
{% endif %}
|
2021-05-26 08:53:05 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
{# For bulk edit forms, include an option to nullify the field #}
|
|
|
|
{% if bulk_nullable %}
|
|
|
|
<div class="form-check my-1">
|
|
|
|
<input type="checkbox" class="form-check-input" name="_nullify" value="{{ field.name }}" id="nullify_{{ field.id_for_label }}" />
|
|
|
|
<label for="nullify_{{ field.id_for_label }}" class="form-check-label">Set Null</label>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-05-26 08:53:05 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
</div>
|
2021-05-26 08:53:05 -07:00
|
|
|
|
2022-11-22 12:02:21 -05:00
|
|
|
</div>
|