forked from ckan/ckanext-scheming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
datetime.html
42 lines (39 loc) · 1.45 KB
/
datetime.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
{% import 'macros/form.html' as form %}
{% set date = data.get(field.field_name + '_date') %}
{% set time = data.get(field.field_name + '_time') %}
{% if not date is string and not time is string %}
{% set date = data.get(field.field_name) %}
{% if date %}
{% set parts = data.get(field.field_name).split() %}
{% set date = parts[0] %}
{% set time = parts[1] %}
{% endif %}
{% endif %}
{% call form.input(
field.field_name + '_date',
id='field-' + field.field_name + '-date',
label= h.scheming_language_text(field.label),
type='date',
value=date,
error=errors[field.field_name + '_date'],
classes=field.classes if 'classes' in field else ['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 %}
{% call form.input(
field.field_name + '_time',
id='field-' + field.field_name + '-time',
label= h.scheming_language_text(field.get('label_time', 'Time')),
type='time',
value=time,
error=errors[field.field_name + '_time'],
classes=field.classes if 'classes' in field else ['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 %}