2022-10-24 14:59:34 +02:00
|
|
|
{% macro entry_required() %}
|
2023-02-26 11:27:41 +01:00
|
|
|
<span class="text-info" title="{{ __('form.required') }}">*</span>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
{% macro info(text) %}
|
|
|
|
<span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="{{ text | e('html_attr') }}"></span>
|
2022-10-24 14:59:34 +02:00
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders an input field wrapped in a DIV with mb-3.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - If not empty a "label" element with this text will be rendered.
|
|
|
|
@param {string} [opt.type="text"] - Optional type of the input field. Defaults to "text".
|
|
|
|
@param {bool} [opt.hide_label=false] - If true the label will be hidden. This could be useful for screenreders.
|
|
|
|
Defaults to false.
|
|
|
|
@param {bool} [opt.required_icon=false] - Whether an asterisk should be displayed after the label
|
|
|
|
to indicate that this field is mandatory.
|
|
|
|
Won't be displayed without a label. Defaults to false.
|
|
|
|
@param {string} [opt.info] - If set an additional info icon will be added to the label with the text as tooltip.
|
|
|
|
Won't be displayed without a label.
|
|
|
|
@param {string} [opt.value=""] - Optional value to set. Defaults to empty string.
|
|
|
|
@param {int} [opt.min_length] - Optional "minlength" attribute value.
|
|
|
|
@param {int} [opt.max_length] - Optional "maxlength" attribute value.
|
|
|
|
@param {int|float|string} [opt.min] - Optional "min" attribute value.
|
|
|
|
@param {int|float|string} [opt.max] - Optional "max" attribute value.
|
|
|
|
@param {int|float} [opt.step] - Optional "step" attribute value.
|
|
|
|
@param {string} [opt.autocomplete] - Optional "autocomplete" attribute value.
|
|
|
|
@param {bool} [opt.required=false] - Whether to add the "required" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.disabled=false] - Whether to add the "disabled" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.readonly=false] - Whether to add the "readonly" attribute. Defaults to false.
|
|
|
|
#}
|
|
|
|
{% macro input(name, label, 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 }}
|
2023-04-19 22:34:08 +02:00
|
|
|
{% if opt.required_icon|default(false) %}
|
2022-10-24 14:59:34 +02:00
|
|
|
{{ _self.entry_required() }}
|
2022-10-03 18:58:04 +02:00
|
|
|
{% endif %}
|
2023-02-26 11:27:41 +01:00
|
|
|
{% if opt.info is defined %}
|
|
|
|
{{ _self.info(opt.info) }}
|
|
|
|
{% endif %}
|
2022-10-03 18:58:04 +02:00
|
|
|
</label>
|
2019-11-28 02:08:18 +01:00
|
|
|
{%- endif %}
|
2020-06-01 15:13:21 +02:00
|
|
|
<input
|
2023-04-19 22:34:08 +02:00
|
|
|
type="{{ opt.type|default('text') }}" class="form-control"
|
2020-06-01 15:13:21 +02:00
|
|
|
id="{{ name }}" name="{{ name }}"
|
2023-08-13 15:56:35 +02:00
|
|
|
value="{{ opt.value|default('') }}"
|
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 %}
|
2022-12-08 17:40:24 +01:00
|
|
|
{%- if opt.step is defined %} step="{{ opt.step }}"{% endif %}
|
2022-12-10 23:05:49 +01:00
|
|
|
{%- if opt.autocomplete is defined %} autocomplete="{{ opt.autocomplete }}"{% 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
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a "number" type input field wrapped in a DIV with mb-3.
|
|
|
|
Also adds buttons to increment / decrement the value.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - If not empty a "label" element with this text will be rendered.
|
|
|
|
@param {bool} [opt.required_icon=false] - Whether an asterisk should be displayed after the label
|
|
|
|
to indicate that this field is mandatory.
|
|
|
|
Won't be displayed without a label. Defaults to false.
|
|
|
|
@param {string} [opt.info] - If set an additional info icon will be added to the label with the text as tooltip.
|
|
|
|
Won't be displayed without a label.
|
|
|
|
@param {string} [opt.value=""] - Optional value to set. Defaults to empty string.
|
|
|
|
@param {int|float|string} [opt.min] - Optional "min" attribute value.
|
|
|
|
@param {int|float|string} [opt.max] - Optional "max" attribute value.
|
|
|
|
@param {int|float} [opt.step] - Optional "step" attribute value.
|
|
|
|
@param {bool} [opt.required=false] - Whether to add the "required" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.disabled=false] - Whether to add the "disabled" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.readonly=false] - Whether to add the "readonly" attribute. Defaults to false.
|
|
|
|
#}
|
2023-02-26 11:27:41 +01:00
|
|
|
{% macro number(name, label, opt) %}
|
|
|
|
<div class="mb-3">
|
2023-05-11 16:57:45 +02:00
|
|
|
{% if label -%}
|
2023-02-26 11:27:41 +01:00
|
|
|
<label class="form-label" for="{{ name }}">{{ label }}</label>
|
2023-04-19 22:34:08 +02:00
|
|
|
{% if opt.required_icon|default(false) %}
|
2023-02-26 11:27:41 +01:00
|
|
|
{{ _self.entry_required() }}
|
|
|
|
{% endif %}
|
|
|
|
{% if opt.info is defined %}
|
|
|
|
{{ _self.info(opt.info) }}
|
|
|
|
{% endif %}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
<div class="input-group">
|
|
|
|
<input
|
|
|
|
type="number" class="form-control"
|
|
|
|
id="{{ name }}" name="{{ name }}"
|
|
|
|
value="{{ opt.value|default('')|escape('html_attr') }}"
|
|
|
|
{%- if opt.min is defined %} min="{{ opt.min }}"{% endif %}
|
|
|
|
{%- if opt.max is defined %} max="{{ opt.max }}"{% endif %}
|
|
|
|
{%- if opt.step is defined %} step="{{ opt.step }}"{% endif %}
|
2023-11-11 18:34:35 +01:00
|
|
|
{%- if opt.required|default(false) %} required{% endif -%}
|
|
|
|
{%- if opt.disabled|default(false) %} disabled{% endif -%}
|
|
|
|
{%- if opt.readonly|default(false) %} readonly{% endif -%}
|
2023-02-26 11:27:41 +01:00
|
|
|
>
|
|
|
|
|
|
|
|
<button class="btn btn-secondary spinner-down" type="button" data-input-id="{{ name }}">
|
|
|
|
<span class="bi bi-dash-lg"></span>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button class="btn btn-secondary spinner-up" type="button" data-input-id="{{ name }}">
|
|
|
|
<span class="bi bi-plus-lg"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a "textarea" element wrapped in a DIV with mb-3.
|
|
|
|
Also adds buttons to increment / decrement the value.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - If not empty a "label" element with this text will be rendered.
|
|
|
|
@param {bool} [opt.required_icon=false] - Whether an asterisk should be displayed after the label
|
|
|
|
to indicate that this field is mandatory.
|
|
|
|
Won't be displayed without a label. Defaults to false.
|
|
|
|
@param {bool} [opt.required] - Whether to add the "required" attribute. Defaults to false.
|
|
|
|
@param {int} [opt.rows=0] - Optional value of the "rows" attriute. Defaults to 0.
|
|
|
|
@param {string} [opt.value=""] - Optional value to set. Defaults to empty string.
|
2023-12-16 03:07:16 +01:00
|
|
|
@param {string} [opt.label_hidden=true] - Optionaly hide the label. Defaults to false.
|
|
|
|
@param {string} [opt.no_div=false] - Optionaly don't add a div. Defaults to false.
|
2023-04-19 22:34:08 +02:00
|
|
|
#}
|
2020-04-05 16:54:45 +02:00
|
|
|
{% macro textarea(name, label, opt) %}
|
2023-12-16 03:07:16 +01:00
|
|
|
{% if not opt.no_div|default(false) -%}
|
|
|
|
<div class="mb-3">
|
|
|
|
{% endif -%}
|
|
|
|
{% if label -%}
|
|
|
|
<label class="form-label
|
|
|
|
{%- if opt.label_hidden|default(false) %} visually-hidden{% endif -%}
|
|
|
|
" for="{{ name }}">
|
|
|
|
{{ label }}
|
|
|
|
</label>
|
2023-04-19 22:34:08 +02:00
|
|
|
{% if opt.required_icon|default(false) %}
|
2023-02-26 11:27:41 +01:00
|
|
|
{{ _self.entry_required() }}
|
|
|
|
{% endif %}
|
|
|
|
{% if opt.info is defined %}
|
|
|
|
{{ _self.info(opt.info) }}
|
|
|
|
{% endif %}
|
2020-04-05 16:54:45 +02:00
|
|
|
{%- endif %}
|
|
|
|
<textarea class="form-control" id="{{ name }}" name="{{ name }}"
|
2023-12-16 03:07:16 +01:00
|
|
|
{%- if opt.required|default(false) %} required{%- endif -%}
|
2023-11-11 18:34:35 +01:00
|
|
|
{%- if opt.rows|default(0) %} rows="{{ opt.rows }}"{%- endif -%}
|
2023-12-16 03:07:16 +01:00
|
|
|
>{{ opt.value|default('') }}</textarea>
|
|
|
|
{% if not opt.no_div|default(false) -%}
|
|
|
|
</div>
|
|
|
|
{%- endif %}
|
2020-04-05 16:54:45 +02:00
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a select element wrapped in a DIV with mb-3.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - If not empty a "label" element with this text will be rendered.
|
|
|
|
@param {{value, description}} data - Select options. "value" will be the option value, "description" the label.
|
|
|
|
@param {string} [opt.selected] - Optional value of an option to initially set as "selected".
|
|
|
|
@param {bool} [opt.required_icon=false] - Whether an asterisk should be displayed after the label
|
|
|
|
to indicate that this field is mandatory.
|
|
|
|
Won't be displayed without a label. Defaults to false.
|
|
|
|
@param {string} [opt.info] - If set an additional info icon will be added to the label with the text as tooltip.
|
|
|
|
Won't be displayed without a label.
|
|
|
|
@param {string} [opt.class] - Optional additional CSS classes to be added to the actual "select" element.
|
|
|
|
@param {bool} [opt.required=false] - Whether to add the "required" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.default_option] - If set a default option with the param as label and an empty value will be added.
|
|
|
|
#}
|
|
|
|
{% macro select(name, label, data, opt) %}
|
2021-04-29 21:58:20 +02:00
|
|
|
<div class="mb-3">
|
2023-05-11 16:57:45 +02:00
|
|
|
{% if label -%}
|
2022-10-24 14:59:34 +02:00
|
|
|
<label class="form-label" for="{{ name }}">
|
|
|
|
{{ label }}
|
2023-04-19 22:34:08 +02:00
|
|
|
{% if opt.required_icon|default(false) %}
|
2022-10-24 14:59:34 +02:00
|
|
|
{{ _self.entry_required() }}
|
|
|
|
{% endif %}
|
2023-02-26 11:27:41 +01:00
|
|
|
{% if opt.info is defined %}
|
|
|
|
{{ _self.info(opt.info) }}
|
|
|
|
{% endif %}
|
2022-10-24 14:59:34 +02:00
|
|
|
</label>
|
2019-11-27 23:43:21 +01:00
|
|
|
{% endif %}
|
2022-06-04 17:55:26 +02:00
|
|
|
<select id="{{ name }}" name="{{ name }}"
|
2023-02-26 11:27:41 +01:00
|
|
|
class="form-control {%- if opt.class is defined %} {{ opt.class }}{% endif %}"
|
2023-12-29 13:32:00 +01:00
|
|
|
{%- if opt.disabled|default(false) %} disabled{%- endif -%}
|
2023-11-11 18:34:35 +01:00
|
|
|
{%- if opt.required|default(false) %} required{%- endif -%}>
|
2022-06-04 17:55:26 +02:00
|
|
|
{%- 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 -%}
|
2023-04-19 22:34:08 +02:00
|
|
|
<option value="{{ value }}"{% if opt.selected is defined and value == opt.selected %} selected{% endif %}>{{ decription }}</option>
|
2019-11-27 23:43:21 +01:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a Bootstrap checkbox element with mb-3.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - Checkbox label
|
|
|
|
@param {string} [opt.value="1"] - Optional value to set. Defaults to "1".
|
|
|
|
@param {bool} [opt.checked=false] - Whether to add the "checked" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.disabled=false] - Whether to add the "disabled" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.raw_label=false] - Whether to use the raw label value (=do not escape). Defaults to false.
|
|
|
|
@param {string} [opt.info] - If set an additional info icon will be added to the label with the text as tooltip.
|
2023-04-01 14:23:52 +02:00
|
|
|
@param {string} [opt.class="mb-3"] - CSS classes for the checkbox element. Defaults to "mb-3".
|
2023-04-19 22:34:08 +02:00
|
|
|
#}
|
|
|
|
{% macro checkbox(name, label, opt) %}
|
2023-04-01 14:23:52 +02:00
|
|
|
<div class="form-check {{ opt.class is defined ? opt.class : 'mb-3' }}">
|
2023-02-26 11:27:41 +01:00
|
|
|
<input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}"
|
2023-04-19 22:34:08 +02:00
|
|
|
value="{{ opt.value|default('1') }}"
|
|
|
|
{%- if opt.checked|default(false) %} checked{% endif %}
|
|
|
|
{%- if opt.disabled|default(false) %} disabled{% endif %}
|
2023-02-26 11:27:41 +01:00
|
|
|
>
|
2022-11-30 00:14:08 +01:00
|
|
|
<label class="form-check-label" for="{{ name }}">
|
2023-04-19 22:34:08 +02:00
|
|
|
{%- if opt.raw_label|default(false) -%}
|
2022-10-13 20:23:22 +02:00
|
|
|
{{ label|raw }}
|
|
|
|
{%- else -%}
|
|
|
|
{{ label }}
|
|
|
|
{%- endif -%}
|
2023-02-26 11:27:41 +01:00
|
|
|
{% if opt.info is defined %}
|
|
|
|
{{ _self.info(opt.info) }}
|
|
|
|
{% endif %}
|
2020-04-05 16:54:45 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a "hidden" type input field.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} value - Field value
|
|
|
|
#}
|
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
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a button.
|
|
|
|
|
|
|
|
@param {string} label - Button label
|
|
|
|
@param {string} [opt.btn_type="secondary"] - Bootstrap button type. Defaults to "secondary".
|
|
|
|
@param {string} [opt.size] - Optional Bootstrap button size to apply, such as "sm", "lg".
|
|
|
|
@param {string} [opt.type] - Optional value for the "type" attribute.
|
|
|
|
@param {string} [opt.name] - Optional value for the "name" attribute.
|
|
|
|
@param {string} [opt.title] - Optional value for the "title" attribute.
|
|
|
|
@param {string} [opt.value] - Optional value for the "value" attribute.
|
|
|
|
Defaults to "1" if only opt.name is provided.
|
|
|
|
@param {string} [opt.icon_left] - Optional icon to be added before the button label.
|
|
|
|
Must be a Bootstrap icon class without prefix, such as "info" or "check".
|
|
|
|
@param {string} [opt.icon_right] - Optional icon to be added after the button label.
|
|
|
|
Must be a Bootstrap icon class without prefix, such as "info" or "check".
|
2023-11-05 01:27:12 +01:00
|
|
|
@param {string} [opt.confirm_title] - Optional value for the confirmation title.
|
|
|
|
@param {string} [opt.confirm_text] - Optional value for the confirmation text.
|
2023-11-16 18:20:50 +01:00
|
|
|
@param {dictionary} [opt.attr] - Optional value for additional attributes like data fields.
|
2023-04-19 22:34:08 +02:00
|
|
|
#}
|
2020-04-05 16:54:45 +02:00
|
|
|
{% macro button(label, opt) %}
|
2023-11-05 16:29:07 +01:00
|
|
|
{%- set icon_left = opt.icon_left is defined ? '<span class="bi bi-' ~ opt.icon_left ~ '"></span>' : '' %}
|
|
|
|
{%- set icon_right = opt.icon_right is defined ? '<span class="bi bi-' ~ opt.icon_right ~ '"></span>' : '' %}
|
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 -%}
|
2023-11-05 01:27:12 +01:00
|
|
|
{%- if opt.confirm_title is defined %} data-confirm_submit_title="{{ opt.confirm_title }}"{% endif -%}
|
|
|
|
{%- if opt.confirm_text is defined %} data-confirm_submit_text="{{ opt.confirm_text }}"{% endif -%}
|
2023-11-05 16:29:07 +01:00
|
|
|
{%- if opt.confirm_button_text is defined %}
|
|
|
|
data-confirm_button_text="{{ icon_left ~ ' ' ~ opt.confirm_button_text ~ ' ' ~ icon_right }}"
|
|
|
|
{%- endif -%}
|
2023-11-16 18:20:50 +01:00
|
|
|
{%- for key, value in opt.attr|default({}) %} {{ key }}="{{ value }}"{% endfor -%}
|
2020-04-05 16:54:45 +02:00
|
|
|
>
|
2023-11-05 16:29:07 +01:00
|
|
|
{{ icon_left|raw }}
|
2020-04-05 16:54:45 +02:00
|
|
|
{{ label }}
|
2023-11-05 16:29:07 +01:00
|
|
|
{{ icon_right|raw }}
|
2020-04-05 16:54:45 +02:00
|
|
|
</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
|
|
|
|
2023-12-08 21:25:24 +01:00
|
|
|
{% macro save(label, opt) %}
|
|
|
|
{{ _self.submit(label|default(' '), {
|
|
|
|
'icon_left': 'save',
|
|
|
|
'title': __('form.save'),
|
|
|
|
}|merge(opt|default({}))) }}
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-11-05 01:27:12 +01:00
|
|
|
{% macro delete(label, opt) %}
|
|
|
|
{{ _self.submit(label|default(' '), {
|
|
|
|
'icon_left': 'trash',
|
|
|
|
'title': __('form.delete'),
|
|
|
|
'name': 'delete',
|
|
|
|
'btn_type': 'danger',
|
|
|
|
'confirm_text': __('confirmation.delete')
|
|
|
|
}|merge(opt|default({}))) }}
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2023-04-19 22:34:08 +02:00
|
|
|
{#
|
|
|
|
Renders a "checkbox" element that will be styled as switch.
|
|
|
|
|
|
|
|
@param {string} name - Will be used as value for "id" and "name" attributes.
|
|
|
|
@param {string} label - Switch label
|
|
|
|
@param {string} [opt.value="1"] - Optional value to set. Defaults to "1".
|
|
|
|
@param {bool} [opt.checked=false] - Whether to add the "checked" attribute. Defaults to false.
|
|
|
|
@param {bool} [opt.disabled=false] - Whether to add the "disabled" attribute. Defaults to false.
|
|
|
|
#}
|
|
|
|
{% macro switch(name, label, opt) %}
|
2021-10-23 17:02:33 +02:00
|
|
|
<div class="form-check form-switch mb-3">
|
2023-02-26 11:27:41 +01:00
|
|
|
<input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}"
|
|
|
|
value="{{ opt.value|default('1') }}"
|
2023-04-19 22:34:08 +02:00
|
|
|
{%- if opt.checked|default(false) %} checked{% endif %}
|
2021-09-24 20:28:51 +02:00
|
|
|
{%- if opt.disabled|default(false) %} disabled{% endif %}
|
|
|
|
>
|
|
|
|
<label class="form-check-label" for="{{ name }}">{{ label }}</label>
|
|
|
|
</div>
|
|
|
|
{%- endmacro %}
|
2023-02-26 11:27:41 +01:00
|
|
|
|
|
|
|
{% macro formData(name, default) -%}
|
|
|
|
{{ session_pop('form-data-' ~ name, default) }}
|
|
|
|
{%- endmacro %}
|