2022-10-24 14:59:34 +02:00
|
|
|
{% macro entry_required() %}
|
|
|
|
<span class="bi bi-exclamation-triangle text-info"></span>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2019-11-28 02:08:18 +01:00
|
|
|
{% macro input(name, label, type, opt) %}
|
2021-04-29 21:58:20 +02:00
|
|
|
<div class="mb-3">
|
2019-11-28 02:08:18 +01:00
|
|
|
{% if label -%}
|
2022-10-03 18:58:04 +02:00
|
|
|
<label for="{{ name }}" class="form-label {% if opt.hide_label|default(false) %}sr-only{% endif %}">
|
|
|
|
{{ label }}
|
|
|
|
{% if opt.entry_required_icon|default(false) %}
|
2022-10-24 14:59:34 +02:00
|
|
|
{{ _self.entry_required() }}
|
2022-10-03 18:58:04 +02:00
|
|
|
{% endif %}
|
|
|
|
</label>
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endif %}
|
2020-06-01 15:13:21 +02:00
|
|
|
<input
|
|
|
|
type="{{ type|default('text') }}" class="form-control"
|
|
|
|
id="{{ name }}" name="{{ name }}"
|
|
|
|
value="{{ opt.value|default('')|escape('html_attr') }}"
|
2022-10-13 20:23:22 +02:00
|
|
|
{%- if opt.min_length is defined %} minlength="{{ opt.min_length }}"{% endif %}
|
|
|
|
{%- if opt.max_length is defined %} maxlength="{{ opt.max_length }}"{% endif %}
|
|
|
|
{%- if opt.min is defined %} min="{{ opt.min }}"{% endif %}
|
|
|
|
{%- if opt.max is defined %} max="{{ opt.max }}"{% endif %}
|
2020-06-01 15:13:21 +02:00
|
|
|
{%- if opt.required|default(false) %}
|
|
|
|
required
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if opt.disabled|default(false) %}
|
|
|
|
disabled
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if opt.readonly|default(false) %}
|
|
|
|
readonly
|
|
|
|
{%- 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) %}
|
2021-04-29 21:58:20 +02:00
|
|
|
<div class="mb-3">
|
2020-04-05 16:54:45 +02:00
|
|
|
{% if label -%}
|
2021-04-29 21:58:20 +02:00
|
|
|
<label class="form-label" for="{{ name }}">{{ label }}</label>
|
2020-04-05 16:54:45 +02:00
|
|
|
{%- endif %}
|
|
|
|
<textarea class="form-control" id="{{ name }}" name="{{ name }}"
|
2020-06-01 15:13:21 +02:00
|
|
|
{%- if opt.required|default(false) %}
|
|
|
|
required
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if opt.rows|default(0) %}
|
|
|
|
rows="{{ opt.rows }}"
|
|
|
|
{%- endif -%}
|
2020-04-05 16:54:45 +02:00
|
|
|
>{{ opt.value|default('') }}</textarea>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2022-06-04 17:55:26 +02:00
|
|
|
{% macro select(name, data, label, selected, opt) %}
|
2021-04-29 21:58:20 +02:00
|
|
|
<div class="mb-3">
|
2019-11-27 23:43:21 +01:00
|
|
|
{% if label -%}
|
2022-10-24 14:59:34 +02:00
|
|
|
<label class="form-label" for="{{ name }}">
|
|
|
|
{{ label }}
|
|
|
|
{% if opt.entry_required_icon|default(false) %}
|
|
|
|
{{ _self.entry_required() }}
|
|
|
|
{% endif %}
|
|
|
|
</label>
|
2019-11-27 23:43:21 +01:00
|
|
|
{% endif %}
|
2022-06-04 17:55:26 +02:00
|
|
|
<select id="{{ name }}" name="{{ name }}"
|
|
|
|
class="form-control {%- if opt.class is defined %} {{ opt.class }}{% endif %}"
|
|
|
|
{%- if opt.required|default(false) %}required{%- endif -%}>
|
|
|
|
{%- if opt.default_option is defined %}
|
|
|
|
<option value="">{{ opt.default_option }}</option>
|
|
|
|
{% endif %}
|
2019-11-27 23:43:21 +01:00
|
|
|
{% for value,decription in data -%}
|
2021-09-24 20:28:51 +02:00
|
|
|
<option value="{{ value }}"{% if value == selected %} selected{% endif %}>{{ decription }}</option>
|
2019-11-27 23:43:21 +01:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2022-10-13 20:23:22 +02:00
|
|
|
{% macro checkbox(name, label, checked, value, disabled, raw_label) %}
|
2021-10-23 17:02:33 +02:00
|
|
|
<div class="form-check mb-3">
|
2020-04-05 16:54:45 +02:00
|
|
|
<label>
|
2021-09-24 20:28:51 +02:00
|
|
|
<input type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}" class="form-check-input"
|
2020-06-01 15:13:21 +02:00
|
|
|
{%- if checked|default(false) %} checked{% endif %}
|
2021-09-24 20:28:51 +02:00
|
|
|
{%- if disabled|default(false) %} disabled{% endif %}
|
2020-06-01 15:13:21 +02:00
|
|
|
>
|
2022-10-13 20:23:22 +02:00
|
|
|
{%- if raw_label|default(false) -%}
|
|
|
|
{{ label|raw }}
|
|
|
|
{%- else -%}
|
|
|
|
{{ label }}
|
|
|
|
{%- endif -%}
|
2020-04-05 16:54:45 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2019-10-08 16:17:06 +02:00
|
|
|
{% macro hidden(name, value) %}
|
2020-05-01 16:29:28 +02:00
|
|
|
<input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value|escape('html_attr') }}">
|
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) %}
|
2021-07-24 18:19:53 +02:00
|
|
|
<button
|
2021-07-29 20:18:40 +02:00
|
|
|
class="btn btn-{{ opt.btn_type|default('secondary') }}
|
2021-09-10 14:30:16 +02:00
|
|
|
{%- if opt.size is defined %} btn-{{ opt.size }}{% endif %}"
|
2020-06-01 15:13:21 +02:00
|
|
|
{%- if opt.type is defined %} type="{{ opt.type }}"{% endif %}
|
|
|
|
{%- if opt.name is defined %} name="{{ opt.name }}"{% endif %}
|
2020-12-06 00:16:15 +01:00
|
|
|
{%- if opt.title is defined %} title="{{ opt.title }}"{% endif %}
|
2020-06-01 15:13:21 +02:00
|
|
|
{%- if opt.value is defined or opt.name is defined %} value="{{ opt.value|default('1') }}"{% endif -%}
|
2020-04-05 16:54:45 +02:00
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
</button>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
{% macro submit(label, opt) %}
|
2021-08-05 01:00:12 +02:00
|
|
|
{{ _self.button(label|default(__('form.submit')), {'type': 'submit', 'btn_type': 'primary'}|merge(opt|default({}))) }}
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endmacro %}
|
2021-09-24 20:28:51 +02:00
|
|
|
|
|
|
|
{% macro switch(name, label, checked, opt) %}
|
2021-10-23 17:02:33 +02:00
|
|
|
<div class="form-check form-switch mb-3">
|
2021-09-24 20:28:51 +02:00
|
|
|
<input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ opt.value|default('1') }}"
|
|
|
|
{%- if checked|default(false) %} checked{% endif %}
|
|
|
|
{%- if opt.disabled|default(false) %} disabled{% endif %}
|
|
|
|
>
|
|
|
|
<label class="form-check-label" for="{{ name }}">{{ label }}</label>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|