engelsystem/resources/views/macros/form.twig

36 lines
1.2 KiB
Twig
Raw Normal View History

{% macro input(name, label, type, opt) %}
2019-10-08 16:17:06 +02:00
<div class="form-group">
{% if label -%}
2019-10-08 16:17:06 +02:00
<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="required"
{%- endif -%}
2019-10-08 16:17:06 +02:00
>
</div>
{%- endmacro %}
2019-10-08 16:17:06 +02: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 %}
2019-10-08 16:17:06 +02:00
{% macro hidden(name, value) %}
<input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value }}">
{%- endmacro %}
2019-10-08 16:17:06 +02:00
{% macro submit(label) %}
<button type="submit" class="btn btn-primary">{{ label|default(__('form.submit')) }}</button>
{%- endmacro %}