|
| 1 | +{% extends "form_div_layout.html.twig" %} |
| 2 | + |
| 3 | +{# Widgets #} |
| 4 | + |
| 5 | +{% block form_widget_simple -%} |
| 6 | + {% if type is not defined or 'file' != type %} |
| 7 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} |
| 8 | + {% endif %} |
| 9 | + {{- parent() -}} |
| 10 | +{%- endblock form_widget_simple %} |
| 11 | + |
| 12 | +{% block textarea_widget -%} |
| 13 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} |
| 14 | + {{- parent() -}} |
| 15 | +{%- endblock textarea_widget %} |
| 16 | + |
| 17 | +{% block submit_widget -%} |
| 18 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %} |
| 19 | + {{- parent() -}} |
| 20 | +{%- endblock %} |
| 21 | + |
| 22 | +{% block button_widget -%} |
| 23 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %} |
| 24 | + {{- parent() -}} |
| 25 | +{%- endblock %} |
| 26 | + |
| 27 | +{% block money_widget -%} |
| 28 | + <div class="input-group"> |
| 29 | + {% set prepend = '{{' == money_pattern[0:2] %} |
| 30 | + {% if not prepend %} |
| 31 | + <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> |
| 32 | + {% endif %} |
| 33 | + {{- block('form_widget_simple') -}} |
| 34 | + {% if prepend %} |
| 35 | + <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> |
| 36 | + {% endif %} |
| 37 | + </div> |
| 38 | +{%- endblock money_widget %} |
| 39 | + |
| 40 | +{% block percent_widget -%} |
| 41 | + <div class="input-group"> |
| 42 | + {{- block('form_widget_simple') -}} |
| 43 | + <span class="input-group-addon">%</span> |
| 44 | + </div> |
| 45 | +{%- endblock percent_widget %} |
| 46 | + |
| 47 | +{% block datetime_widget -%} |
| 48 | + {% if widget == 'single_text' %} |
| 49 | + {{- block('form_widget_simple') -}} |
| 50 | + {% else %} |
| 51 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} |
| 52 | + <div {{ block('widget_container_attributes') }}> |
| 53 | + {{ form_errors(form.date) }} |
| 54 | + {{ form_errors(form.time) }} |
| 55 | + {{ form_widget(form.date, { datetime: true } ) }} |
| 56 | + {{ form_widget(form.time, { datetime: true } ) }} |
| 57 | + </div> |
| 58 | + {% endif %} |
| 59 | +{%- endblock datetime_widget %} |
| 60 | + |
| 61 | +{% block date_widget -%} |
| 62 | + {% if widget == 'single_text' %} |
| 63 | + {{- block('form_widget_simple') -}} |
| 64 | + {% else %} |
| 65 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} |
| 66 | + {% if datetime is not defined or not datetime %} |
| 67 | + <div {{ block('widget_container_attributes') -}}> |
| 68 | + {% endif %} |
| 69 | + {{ date_pattern|replace({ |
| 70 | + '{{ year }}': form_widget(form.year), |
| 71 | + '{{ month }}': form_widget(form.month), |
| 72 | + '{{ day }}': form_widget(form.day), |
| 73 | + })|raw }} |
| 74 | + {% if datetime is not defined or not datetime %} |
| 75 | + </div> |
| 76 | + {% endif %} |
| 77 | + {% endif %} |
| 78 | +{%- endblock date_widget %} |
| 79 | + |
| 80 | +{% block time_widget -%} |
| 81 | + {% if widget == 'single_text' %} |
| 82 | + {{- block('form_widget_simple') -}} |
| 83 | + {% else %} |
| 84 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} |
| 85 | + {% if datetime is not defined or false == datetime %} |
| 86 | + <div {{ block('widget_container_attributes') -}}> |
| 87 | + {% endif %} |
| 88 | + {{ form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} |
| 89 | + {% if datetime is not defined or false == datetime %} |
| 90 | + </div> |
| 91 | + {% endif %} |
| 92 | + {% endif %} |
| 93 | +{%- endblock time_widget %} |
| 94 | + |
| 95 | +{% block choice_widget_collapsed -%} |
| 96 | + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} |
| 97 | + {{- parent() -}} |
| 98 | +{%- endblock %} |
| 99 | + |
| 100 | +{% block choice_widget_expanded -%} |
| 101 | + {% if '-inline' in label_attr.class|default('') %} |
| 102 | + <div class="control-group"> |
| 103 | + {% for child in form %} |
| 104 | + {{ form_widget(child, { |
| 105 | + parent_label_class: label_attr.class|default(''), |
| 106 | + }) }} |
| 107 | + {% endfor %} |
| 108 | + </div> |
| 109 | + {% else %} |
| 110 | + <div {{ block('widget_container_attributes') }}> |
| 111 | + {% for child in form %} |
| 112 | + {{ form_widget(child, { |
| 113 | + parent_label_class: label_attr.class|default(''), |
| 114 | + }) }} |
| 115 | + {% endfor %} |
| 116 | + </div> |
| 117 | + {% endif %} |
| 118 | +{%- endblock choice_widget_expanded %} |
| 119 | + |
| 120 | +{% block checkbox_widget -%} |
| 121 | + {% set parent_label_class = parent_label_class|default('') %} |
| 122 | + {% if 'checkbox-inline' in parent_label_class %} |
| 123 | + {{ form_label(form, null, { widget: parent() }) }} |
| 124 | + {% else %} |
| 125 | + <div class="checkbox"> |
| 126 | + {{ form_label(form, null, { widget: parent() }) }} |
| 127 | + </div> |
| 128 | + {% endif %} |
| 129 | +{%- endblock checkbox_widget %} |
| 130 | + |
| 131 | +{% block radio_widget -%} |
| 132 | + {% set parent_label_class = parent_label_class|default('') %} |
| 133 | + {% if 'radio-inline' in parent_label_class %} |
| 134 | + {{ form_label(form, null, { widget: parent() }) }} |
| 135 | + {% else %} |
| 136 | + <div class="radio"> |
| 137 | + {{ form_label(form, null, { widget: parent() }) }} |
| 138 | + </div> |
| 139 | + {% endif %} |
| 140 | +{%- endblock radio_widget %} |
| 141 | + |
| 142 | +{# Labels #} |
| 143 | + |
| 144 | +{% block form_label -%} |
| 145 | + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) %} |
| 146 | + {{- parent() -}} |
| 147 | +{%- endblock form_label %} |
| 148 | + |
| 149 | +{% block choice_label %} |
| 150 | + {# remove the checkbox-inline, it's only use full for embed labels #} |
| 151 | + {% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': ''})|trim}) %} |
| 152 | + {{- block('form_label') -}} |
| 153 | +{% endblock %} |
| 154 | + |
| 155 | +{% block checkbox_label -%} |
| 156 | + {{- block('checkbox_radio_label') -}} |
| 157 | +{%- endblock checkbox_label %} |
| 158 | + |
| 159 | +{% block radio_label -%} |
| 160 | + {{- block('checkbox_radio_label') -}} |
| 161 | +{%- endblock radio_label %} |
| 162 | + |
| 163 | +{% block checkbox_radio_label %} |
| 164 | + {% if required %} |
| 165 | + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} |
| 166 | + {% endif %} |
| 167 | + {% if parent_label_class is defined %} |
| 168 | + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %} |
| 169 | + {% endif %} |
| 170 | + {% if label is empty %} |
| 171 | + {% set label = name|humanize %} |
| 172 | + {% endif %} |
| 173 | + <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> |
| 174 | + {{ widget|raw }} |
| 175 | + {{ label|trans({}, translation_domain) }} |
| 176 | + </label> |
| 177 | +{% endblock checkbox_radio_label %} |
| 178 | + |
| 179 | +{# Rows #} |
| 180 | + |
| 181 | +{% block form_row -%} |
| 182 | + <div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}"> |
| 183 | + {{ form_label(form) }} |
| 184 | + {{ form_widget(form) }} |
| 185 | + {{ form_errors(form) }} |
| 186 | + </div> |
| 187 | +{%- endblock form_row %} |
| 188 | + |
| 189 | +{% block choice_row -%} |
| 190 | + {% set force_error = true %} |
| 191 | + {{ block('form_row') }} |
| 192 | +{%- endblock choice_row %} |
| 193 | + |
| 194 | +{% block date_row -%} |
| 195 | + {% set force_error = true %} |
| 196 | + {{ block('form_row') }} |
| 197 | +{%- endblock date_row %} |
| 198 | + |
| 199 | +{% block time_row -%} |
| 200 | + {% set force_error = true %} |
| 201 | + {{ block('form_row') }} |
| 202 | +{%- endblock time_row %} |
| 203 | + |
| 204 | +{% block datetime_row -%} |
| 205 | + {% set force_error = true %} |
| 206 | + {{ block('form_row') }} |
| 207 | +{%- endblock datetime_row %} |
| 208 | + |
| 209 | +{% block checkbox_row -%} |
| 210 | + <div class="form-group{% if not valid %} has-error{% endif %}"> |
| 211 | + {{ form_widget(form) }} |
| 212 | + {{ form_errors(form) }} |
| 213 | + </div> |
| 214 | +{%- endblock checkbox_row %} |
| 215 | + |
| 216 | +{% block radio_row -%} |
| 217 | + <div class="form-group{% if not valid %} has-error{% endif %}"> |
| 218 | + {{ form_widget(form) }} |
| 219 | + {{ form_errors(form) }} |
| 220 | + </div> |
| 221 | +{%- endblock radio_row %} |
| 222 | + |
| 223 | +{# Errors #} |
| 224 | + |
| 225 | +{% block form_errors -%} |
| 226 | + {% if errors|length > 0 %} |
| 227 | + {% if form.parent %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %} |
| 228 | + {{- parent() -}} |
| 229 | + {% if form.parent %}</span>{% else %}</div>{% endif %} |
| 230 | + {% endif %} |
| 231 | +{%- endblock form_errors %} |
0 commit comments