{% load widget_tweaks i18n allink_form_tags %}
{% if field.is_hidden %}
{{ field }}
{% else %}
{% block control_group %}
{% block label %}
{% if not nolabel and field|widget_type != 'checkboxinput' and field|widget_type != 'radioselect' %}
{% spaceless %}
{% endspaceless %}
{% endif %}
{% endblock %}
{% block controls %}
{% block widget %}
{# Date AND/OR Time #}
{% if field|widget_type == 'datetimeinput' or field|widget_type == 'dateinput' or field|widget_type == 'timeinput' %}
{% comment %}
Need a specific widget attribute? Here's how to get it:
{{field.field.widget.attrs.enableTime}}
{% endcomment %}
{% if field.field.required %}
{% render_field field class+="datepicker form-control" required="required" %}
{% else %}
{% render_field field class+="datepicker form-control" %}
{% endif %}
{# If a date has to be selected, show the calendar button #}
{% if field|widget_type == 'datetimeinput' or field|widget_type == 'dateinput' %}
{% trans "Open Calendar" %}
{# if it's time only, we want a time button #}
{% else %}
{% trans "Open Time Picker" %}
{% endif %}
{# If the field is OPTIONAL, we have to be able to clear it #}
{% if not field.field.required %}
{% trans "Clear Field" %}
{% endif %}
{# Radio #}
{% elif field|widget_type == 'radioselect' %}
{% if not nolabel %}
{{ field.label|safe }}
{% if is_optional %}{% trans "Optional" %}{% endif %}
{% endif %}
{% for choice in field %}
{% endfor %}
{# Default #}
{% else %}
{% comment %}
Default (with placeholder):
Only display an input placeholder in the following cases:
1: In a "Form Plugin" we can choose a "placeholder-enabled" option that will add the placeholder attributes
2: A 'placeholder_enabled=True' is passed to either a form or a form_field include-tag
{% endcomment %}
{% if instance.label_layout == 'placeholder' or placeholder_enabled == True %}
{# backward compatibility #}
{% if field.field.widget.attrs.placeholder %}
{% if field.field.required %}
{% render_field field class+="form-control" required="required" placeholder=field.field.widget.attrs.placeholder %}
{% else %}
{% render_field field class+="form-control" placeholder=field.field.widget.attrs.placeholder %}
{% endif %}
{% else %}
{% if field.field.required %}
{% render_field field class+="form-control" required="required" placeholder=field.label %}
{% else %}
{% render_field field class+="form-control" placeholder=field.label %}
{% endif %}
{% endif %}
{% comment %}
Default (withOUT placeholder):
Forcefully set placeholder='', to make sure they are NOT being displayed
{% endcomment %}
{% else %}
{% if field.field.required %}
{% render_field field class+="form-control" required="required" placeholder='' %}
{% else %}
{% render_field field class+="form-control" placeholder='' %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
{% block errors %}
{% if not noerror %}
{% if field.errors %}
{% for error in field.errors %}
{{ error }}
{% endfor %}
{% endif %}
{% endif %}
{% endblock %}
{% block help_text %}
{% if field.help_text %}
{# We allow HTML within form help fields #}
{{ field.help_text|safe }}
{% endif %}
{% endblock %}