2019-11-28 02:08:18 +01:00
|
|
|
{% macro input(name, label, type, opt) %}
|
2019-10-08 16:17:06 +02:00
|
|
|
<div class="form-group">
|
2019-11-28 02:08:18 +01:00
|
|
|
{% if label -%}
|
2019-10-08 16:17:06 +02:00
|
|
|
<label for="{{ name }}">{{ label }}</label>
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endif %}
|
|
|
|
<input type="{{ type|default('text') }}" class="form-control"
|
|
|
|
id="{{ name }}" name="{{ name }}"
|
|
|
|
value="{{ opt.value|default('') }}"
|
|
|
|
{%- if opt.required|default(false) %}
|
|
|
|
required="required"
|
|
|
|
{%- endif -%}
|
2019-10-08 16:17:06 +02:00
|
|
|
>
|
|
|
|
</div>
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endmacro %}
|
2019-10-08 16:17:06 +02:00
|
|
|
|
2020-04-05 16:54:45 +02:00
|
|
|
{% macro textarea(name, label, opt) %}
|
|
|
|
<div class="form-group">
|
|
|
|
{% if label -%}
|
|
|
|
<label for="{{ name }}">{{ label }}</label>
|
|
|
|
{%- endif %}
|
|
|
|
<textarea class="form-control" id="{{ name }}" name="{{ name }}"
|
|
|
|
{%- if opt.required|default(false) %}
|
|
|
|
required="required"
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if opt.rows|default(0) %}
|
|
|
|
rows="{{ opt.rows }}"
|
|
|
|
{%- endif -%}
|
|
|
|
>{{ opt.value|default('') }}</textarea>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2019-11-27 23:43:21 +01:00
|
|
|
{% macro select(name, data, label, selected) %}
|
|
|
|
<div class="form-group">
|
|
|
|
{% if label -%}
|
|
|
|
<label for="{{ name }}">{{ label }}</label>
|
|
|
|
{% endif %}
|
|
|
|
<select id="{{ name }}" name="{{ name }}" class="form-control">
|
|
|
|
{% for value,decription in data -%}
|
|
|
|
<option value="{{ value }}" {% if name == selected %} selected{% endif %}>{{ decription }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2020-04-05 16:54:45 +02:00
|
|
|
{% macro checkbox(name, label, checked, value) %}
|
|
|
|
<div class="checkbox">
|
|
|
|
<label>
|
|
|
|
<input type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}"
|
|
|
|
{%- if checked|default(false) %} checked="checked"{% endif %}>
|
|
|
|
{{ label }}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2019-10-08 16:17:06 +02:00
|
|
|
{% macro hidden(name, value) %}
|
|
|
|
<input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value }}">
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endmacro %}
|
2019-10-08 16:17:06 +02:00
|
|
|
|
2020-04-05 16:54:45 +02:00
|
|
|
{% macro button(label, opt) %}
|
|
|
|
<button class="btn btn-{{ opt.btn_type|default('primary') }}"
|
|
|
|
{%- if opt.type is defined %} type="{{ opt.type }}"{% endif %}
|
|
|
|
{%- if opt.name is defined %} name="{{ opt.name }}"{% endif %}
|
|
|
|
{%- if opt.value is defined or opt.name is defined %} value="{{ opt.value|default('1') }}"{% endif -%}
|
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
</button>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
{% macro submit(label, opt) %}
|
|
|
|
{{ _self.button(label|default(__('form.submit')), opt|default({})|merge({'type': 'submit'})) }}
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endmacro %}
|