[993] | 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 | |
---|
[1001] | 11 | {% block field_submit %} |
---|
| 12 | {% spaceless %} |
---|
| 13 | {% set type = type|default('submit') %} |
---|
| 14 | {{ block('field_input') }} |
---|
| 15 | {% endspaceless %} |
---|
| 16 | {% endblock field_submit %} |
---|
| 17 | |
---|
[993] | 18 | {% block field_textarea %} |
---|
| 19 | {% spaceless %} |
---|
| 20 | {{ block('label') }} |
---|
| 21 | <textarea {{ block('field_attr') }}>{{ value }}</textarea> |
---|
| 22 | {% endspaceless %} |
---|
| 23 | {% endblock field_textarea %} |
---|
| 24 | |
---|
| 25 | {% block field_password %} |
---|
| 26 | {% spaceless %} |
---|
| 27 | {% set type = type|default('password') %} |
---|
| 28 | {{ block('field_input') }} |
---|
| 29 | {% endspaceless %} |
---|
| 30 | {% endblock field_password %} |
---|
| 31 | |
---|
| 32 | {% block field_hidden %} |
---|
| 33 | {% set type = type|default('hidden') %} |
---|
| 34 | {{ block('field_input') }} |
---|
| 35 | {% endblock field_hidden %} |
---|
| 36 | |
---|
| 37 | {% block field_input %} |
---|
| 38 | {% spaceless %} |
---|
| 39 | {% set type = type|default('text') %} |
---|
| 40 | {{ block('label') }} |
---|
| 41 | <input type="{{ type }}" {{ block('field_attr') }} {% if value is not empty %}value="{{ value }}" {% endif %} /> |
---|
| 42 | {% endspaceless %} |
---|
| 43 | {% endblock field_input %} |
---|
| 44 | |
---|
| 45 | {% block field_checkbox %} |
---|
| 46 | {% spaceless %} |
---|
| 47 | {% if label is not empty %} |
---|
| 48 | <label for="{{name}}" class="classic"> |
---|
| 49 | {% endif %} |
---|
| 50 | <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
---|
| 51 | {% if label is not empty %} |
---|
| 52 | {{ label }}</label> |
---|
| 53 | {% endif %} |
---|
| 54 | {% endspaceless %} |
---|
| 55 | {% endblock field_checkbox %} |
---|
| 56 | |
---|
| 57 | {% block field_attr %} |
---|
| 58 | {% spaceless %} |
---|
| 59 | id="{{id}}" name="{{name}}" {% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %} |
---|
| 60 | {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %} |
---|
| 61 | {% endspaceless %} |
---|
| 62 | {% endblock field_attr %} |
---|
| 63 | |
---|
| 64 | {% block field_options %} |
---|
| 65 | {% spaceless %} |
---|
| 66 | {% for choice, label in options %} |
---|
| 67 | {% if _form_is_choice_group(label) %} |
---|
| 68 | <optgroup label="{{ choice }}"> |
---|
| 69 | {% for nestedChoice, nestedLabel in label %} |
---|
| 70 | <option value="{{ nestedChoice }}"{% if nestedChoice == value %} selected="selected"{% endif %}>{{ nestedLabel }}</option> |
---|
| 71 | {% endfor %} |
---|
| 72 | </optgroup> |
---|
| 73 | {% else %} |
---|
| 74 | <option value="{{ choice }}"{% if choice == value %} selected="selected"{% endif %}>{{ label|raw }}</option> |
---|
| 75 | {% endif %} |
---|
| 76 | {% endfor %} |
---|
| 77 | {% endspaceless %} |
---|
| 78 | {% endblock field_options %} |
---|
| 79 | |
---|
| 80 | {% block field_combo %} |
---|
| 81 | {% spaceless %} |
---|
| 82 | {{ block('label') }} |
---|
| 83 | <select {{ block('field_attr') }}> |
---|
| 84 | {{ block('field_options') }} |
---|
| 85 | </select> |
---|
| 86 | {% endspaceless %} |
---|
| 87 | {% endblock field_combo %} |
---|
| 88 | |
---|
| 89 | {% block label %} |
---|
| 90 | {% spaceless %} |
---|
| 91 | {% if label is not empty %} |
---|
| 92 | <label for="{{name}}" {% if required is not empty %}class="required"> <abbr title="{{__('Required field')}}">*</abbr>{% else %}>{% endif %} {{label}}</label> |
---|
| 93 | {% endif %} |
---|
| 94 | {% endspaceless %} |
---|
| 95 | {% endblock label %} |
---|