Dotclear

source: inc/admin/default-templates/forms/form_layout.html.twig @ 1517:055caf38ee9f

Revision 1517:055caf38ee9f, 3.8 KB checked in by Dsls, 11 years ago (diff)

removed superfluous debug log
Added twig function "form_hidden" to display hidden fields where the user wants, instead of just before the end of form
(enables to be hxtml validator-friendly)

Line 
1{# Form Fields #}
2{# Heavily inspired from Symfony Framework #}
3
4{% block field_text %}
5{% spaceless %}
6     {% set type = type|default('text') %}
7     {{ block('field_input') }}
8{% endspaceless %}
9{% endblock field_text %}
10
11{% block field_submit %}
12{% spaceless %}
13     {% set type = type|default('submit') %}
14     {{ block('field_input') }}
15{% endspaceless %}
16{% endblock field_submit %}
17
18{% block field_textarea %}
19{% spaceless %}
20     {{ block('startlabel') }}
21    <textarea {{ block('field_attr') }}>{{ value }}</textarea>
22    {{ block('endlabel') }}
23{% endspaceless %}
24{% endblock field_textarea %}
25
26{% block field_password %}
27{% spaceless %}
28     {% set type = type|default('password') %}
29     {{ block('field_input') }}
30{% endspaceless %}
31{% endblock field_password %}
32
33{% block field_hidden %}
34{% spaceless %}
35    {% set type = type|default('hidden') %}
36    {{ block('field_input') }}
37{% endspaceless %}
38{% endblock field_hidden %}
39
40{% block field_input %}
41{% autoescape "html" %}
42{% spaceless %}
43    {% set type = type|default('text') %}
44    {{ block('startlabel') }}
45     <input type="{{ type }}" {{ block('field_attr') }} {% if value is not empty %}value="{{ value }}" {% endif %} />
46    {{ block('endlabel') }}
47{% endspaceless %}
48{% endautoescape %}
49{% endblock field_input %}
50
51{% block field_checkbox %}
52{% spaceless %}
53{% set type = type|default('checkbox') %}
54{% set nestedlabel = true %}
55{% set labelclass = "classic" %}
56{% set descafter = true %}
57    {{ block('field_input') }}
58{% endspaceless %}
59{% endblock field_checkbox %}
60
61{% block field_attr %}
62{% spaceless %}
63 {% if id %}id="{{id}}"{% endif %} name="{{name}}" {% if read_only %} disabled="disabled"{% endif %}{#{% if required %} required="required"{% endif %}#}{% if maxlength %} maxlength="{{ maxlength }}"{% endif %}{% if checked %} checked="{{ checked }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
64    {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
65{% endspaceless %}
66{% endblock field_attr %}
67
68{% block field_options %}
69{% spaceless %}
70    {% for choice, label in options %}
71        {% if _form_is_choice_group(label) %}
72            <optgroup label="{{ choice }}">
73                {% for nestedChoice, nestedLabel in label %}
74                    <option value="{{ nestedChoice }}"{% if nestedChoice == value %} selected="selected"{% endif %}>{{ nestedLabel }}</option>
75                {% endfor %}
76            </optgroup>
77        {% else %}
78            <option value="{{ choice }}"{% if choice == value %} selected="selected"{% endif %}>{{ label|raw }}</option>
79        {% endif %}
80    {% endfor %}
81{% endspaceless %}
82{% endblock field_options %}
83
84{% block field_combo %}
85{% spaceless %}
86    {{ block('startlabel') }}
87    <select {{ block('field_attr') }}>
88        {{ block('field_options') }}
89    </select>
90    {{ block('endlabel') }}
91{% endspaceless %}
92{% endblock field_combo %}
93
94{% block startlabel %}
95{% spaceless %}
96    {% if label is not empty %}
97        {% if required is not empty %}
98            {% set labelclass = labelclass ~ " required" %}
99        {% endif %}
100        <label for="{{name}}" {% if labelclass is not empty %}class="{{labelclass}}"{% endif %}>{% if required is not empty %}<abbr title="{{__('Required field')}}">*</abbr>{% endif %}
101
102          {% if descafter is empty %} {{label}} {% endif %}
103        {% if nestedlabel is empty %}</label> {% endif %}
104    {% endif %}
105{% endspaceless %}
106{% endblock startlabel %}
107
108{% block endlabel %}
109{% spaceless %}
110    {% if label is not empty %}
111          {% if descafter %} {{label}} {% endif %}
112        {% if nestedlabel is not empty %}</label>{% endif %}
113    {% endif %}
114{% endspaceless %}
115{% endblock endlabel %}
116
117{%- block beginform -%}
118<form {% if class is not empty -%} class="{{class|join(' ')}}" {%- endif %} {% if id is not empty -%} id="{{id}}" {%- endif %}
119 method="{{method}}" action="{{action}}">
120{%- endblock beginform -%}
121
122{% block endform -%}
123</form>
124{%- endblock endform %}
Note: See TracBrowser for help on using the repository browser.

Sites map