This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
/
field.html
47 lines (43 loc) · 1.74 KB
/
field.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{% if privacy %}
<div class="privacy-controls">
<span class="info glyphicon glyphicon-eye-open" aria-hidden="true" title="{{ _('Choose visibility group for this field') }}"></span>
<div class="btn-group btn-group-xs" role="group">
{% for value, text in field.field.choices %}
{% if value == 1 %}
<button type="button" class="btn btn-default active">{{ text }}</button>
{% else %}
<button type="button" class="privacy-toggle btn btn-default {% if value == field.value()|int %}active{% endif %}" data-target="{{ field.name }}" data-value="{{ value }}">{{ text }}</button>
{% endif %}
{% endfor %}
<input type="hidden" value="{{ field.value() }}" name="{{ field.html_name }}" id="{{ field.auto_id }}">
</div>
{% if field.errors %}
<div class="error-message">{{ field.errors }}</div>
{% endif %}
</div>
{% else %}
{% if field|is_checkbox %}
{# for checkbox only, include the control inside the label element and before the label text #}
<label class="checkbox{% if field.field.required %} required{% endif %}">
{{ field }} <span>{{ field.label }}</span>
</label>
{% elif field.field.required or flag_required %}
{# put a required class on the label, in case we want to style it #}
{{ field.label_tag(attrs={'class': 'required'}) }}
{% else %}
{{ field.label_tag() }}
{% endif %}
<div class="form-group{% if field.errors %} error{% endif %}">
{% if not field|is_checkbox %}
{{ field }}
{% endif %}
{% for error in field.errors %}
<span class="error-message">{{ error }}</span>
{% endfor %}
{% if field.help_text %}
<p class="help-block">
{{ field.help_text }}
</p>
{% endif %}
</div>
{% endif %}