summaryrefslogtreecommitdiff
path: root/resources/views/macros/form.twig
blob: ece85fcfc23cb419b0207eae19cd9b12c60c61bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{% 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="required"
                {%- endif -%}
        >
    </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 %}

{% macro hidden(name, value) %}
    <input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value }}">
{%- endmacro %}

{% macro submit(label) %}
    <button type="submit" class="btn btn-primary">{{ label|default(__('form.submit')) }}</button>
{%- endmacro %}