You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB
Plaintext

{% macro input(name, label, type, opt) %}
<div class="form-group">
{% if label -%}
<label for="{{ name }}">{{ label }}</label>
{%- endif %}
<input type="{{ type|default('text') }}" class="form-control"
id="{{ name }}" name="{{ name }}"
value="{{ opt.value|default('') }}"
{%- if opt.required|default(false) %}
required
{%- endif -%}
{%- if opt.disabled|default(false) %}
disabled
{%- endif -%}
{%- if opt.readonly|default(false) %}
readonly
{%- endif -%}
>
</div>
{%- endmacro %}
5 years ago
{% 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
5 years ago
{%- endif -%}
{%- if opt.rows|default(0) %}
rows="{{ opt.rows }}"
{%- endif -%}
>{{ opt.value|default('') }}</textarea>
</div>
{%- endmacro %}
{% 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 %}
5 years ago
{% 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{% endif %}>
5 years ago
{{ label }}
</label>
</div>
{%- endmacro %}
{% macro hidden(name, value) %}
<input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value }}">
{%- endmacro %}
5 years ago
{% 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'})) }}
{%- endmacro %}