forked from ckan/ckanext-scheming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.html
33 lines (31 loc) · 1.16 KB
/
select.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
{% import 'macros/form.html' as form %}
{%- set options=[] -%}
{%- set form_restrict_choices_to=field.get('form_restrict_choices_to') -%}
{%- if not h.scheming_field_required(field) or
field.get('form_include_blank_choice', false) -%}
{%- do options.append({'value': '', 'text': ''}) -%}
{%- endif -%}
{%- for c in h.scheming_field_choices(field) -%}
{%- if not form_restrict_choices_to or c.value in form_restrict_choices_to -%}
{%- do options.append({
'value': c.value|string,
'text': h.scheming_language_text(c.label) }) -%}
{%- endif -%}
{%- endfor -%}
{%- if field.get('sorted_choices') -%}
{%- set options = options|sort(case_sensitive=false, attribute='text') -%}
{%- endif -%}
{% call form.select(
field.field_name,
id='field-' + field.field_name,
label=h.scheming_language_text(field.label),
options=options,
selected=data[field.field_name],
error=errors[field.field_name],
classes=['control-medium'],
attrs=dict({"class": "form-control"}, **(field.get('form_attrs', {}))),
is_required=h.scheming_field_required(field)
)
%}
{%- snippet 'scheming/form_snippets/help_text.html', field=field -%}
{% endcall %}