Advertisement
Guest User

bootstrap theme

a guest
Oct 13th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.50 KB | None | 0 0
  1. {% use "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 button_widget -%}
  18.     {% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %}
  19.     {{- parent() -}}
  20. {%- endblock %}
  21.  
  22. {% block money_widget -%}
  23.     <div class="input-group">
  24.         {% set prepend = '{{' == money_pattern[0:2] %}
  25.         {% if not prepend %}
  26.             <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
  27.         {% endif %}
  28.         {{- block('form_widget_simple') -}}
  29.         {% if prepend %}
  30.             <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
  31.         {% endif %}
  32.     </div>
  33. {%- endblock money_widget %}
  34.  
  35. {% block percent_widget -%}
  36.     <div class="input-group">
  37.         {{- block('form_widget_simple') -}}
  38.         <span class="input-group-addon">%</span>
  39.     </div>
  40. {%- endblock percent_widget %}
  41.  
  42. {% block datetime_widget -%}
  43.     {% if widget == 'single_text' %}
  44.         {{- block('form_widget_simple') -}}
  45.     {% else -%}
  46.         {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
  47.         <div {{ block('widget_container_attributes') }}>
  48.             {{- form_errors(form.date) -}}
  49.             {{- form_errors(form.time) -}}
  50.             {{- form_widget(form.date, { datetime: true } ) -}}
  51.             {{- form_widget(form.time, { datetime: true } ) -}}
  52.         </div>
  53.     {%- endif %}
  54. {%- endblock datetime_widget %}
  55.  
  56. {% block date_widget -%}
  57.     {% if widget == 'single_text' %}
  58.         {{- block('form_widget_simple') -}}
  59.     {% else -%}
  60.         {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
  61.         {% if datetime is not defined or not datetime -%}
  62.             <div {{ block('widget_container_attributes') -}}>
  63.         {%- endif %}
  64.             {{- date_pattern|replace({
  65.                 '{{ year }}': form_widget(form.year),
  66.                 '{{ month }}': form_widget(form.month),
  67.                 '{{ day }}': form_widget(form.day),
  68.             })|raw -}}
  69.         {% if datetime is not defined or not datetime -%}
  70.             </div>
  71.         {%- endif -%}
  72.     {% endif %}
  73. {%- endblock date_widget %}
  74.  
  75. {% block time_widget -%}
  76.     {% if widget == 'single_text' %}
  77.         {{- block('form_widget_simple') -}}
  78.     {% else -%}
  79.         {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
  80.         {% if datetime is not defined or false == datetime -%}
  81.             <div {{ block('widget_container_attributes') -}}>
  82.         {%- endif -%}
  83.         {{- form_widget(form.hour) }}{% if with_minutes %}:{{ form_widget(form.minute) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
  84.         {% if datetime is not defined or false == datetime -%}
  85.             </div>
  86.         {%- endif -%}
  87.     {% endif %}
  88. {%- endblock time_widget %}
  89.  
  90. {% block choice_widget_collapsed -%}
  91.     {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
  92.     {{- parent() -}}
  93. {%- endblock %}
  94.  
  95. {% block choice_widget_expanded -%}
  96.     {% if '-inline' in label_attr.class|default('') -%}
  97.         <div class="control-group">
  98.             {%- for child in form %}
  99.                 {{- form_widget(child, {
  100.                     parent_label_class: label_attr.class|default(''),
  101.                     translation_domain: choice_translation_domain,
  102.                 }) -}}
  103.             {% endfor -%}
  104.         </div>
  105.     {%- else -%}
  106.         <div {{ block('widget_container_attributes') }}>
  107.             {%- for child in form %}
  108.                 {{- form_widget(child, {
  109.                     parent_label_class: label_attr.class|default(''),
  110.                     translation_domain: choice_translation_domain,
  111.                 }) -}}
  112.             {% endfor -%}
  113.         </div>
  114.     {%- endif %}
  115. {%- endblock choice_widget_expanded %}
  116.  
  117. {% block checkbox_widget -%}
  118.     {% set parent_label_class = parent_label_class|default('') -%}
  119.     {% if 'checkbox-inline' in parent_label_class %}
  120.         {{- form_label(form, null, { widget: parent() }) -}}
  121.     {% else -%}
  122.         <div class="checkbox">
  123.             {{- form_label(form, null, { widget: parent() }) -}}
  124.         </div>
  125.     {%- endif %}
  126. {%- endblock checkbox_widget %}
  127.  
  128. {% block radio_widget -%}
  129.     {%- set parent_label_class = parent_label_class|default('') -%}
  130.     {% if 'radio-inline' in parent_label_class %}
  131.         {{- form_label(form, null, { widget: parent() }) -}}
  132.     {% else -%}
  133.         <div class="radio">
  134.             {{- form_label(form, null, { widget: parent() }) -}}
  135.         </div>
  136.     {%- endif %}
  137. {%- endblock radio_widget %}
  138.  
  139. {# Labels #}
  140.  
  141. {% block form_label -%}
  142.     {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%}
  143.     {{- parent() -}}
  144. {%- endblock form_label %}
  145.  
  146. {% block choice_label -%}
  147.     {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #}
  148.     {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%}
  149.     {{- block('form_label') -}}
  150. {% endblock %}
  151.  
  152. {% block checkbox_label -%}
  153.     {{- block('checkbox_radio_label') -}}
  154. {%- endblock checkbox_label %}
  155.  
  156. {% block radio_label -%}
  157.     {{- block('checkbox_radio_label') -}}
  158. {%- endblock radio_label %}
  159.  
  160. {% block checkbox_radio_label %}
  161.     {# Do not display the label if widget is not defined in order to prevent double label rendering #}
  162.     {% if widget is defined %}
  163.         {% if required %}
  164.             {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
  165.         {% endif %}
  166.         {% if parent_label_class is defined %}
  167.             {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
  168.         {% endif %}
  169.         {% if label is not same as(false) and label is empty %}
  170.             {% set label = name|humanize %}
  171.         {% endif %}
  172.         <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
  173.             {{- widget|raw -}}
  174.             {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
  175.         </label>
  176.     {% endif %}
  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 button_row -%}
  190.     <div class="form-group">
  191.         {{- form_widget(form) -}}
  192.     </div>
  193. {%- endblock button_row %}
  194.  
  195. {% block choice_row -%}
  196.     {% set force_error = true %}
  197.     {{- block('form_row') }}
  198. {%- endblock choice_row %}
  199.  
  200. {% block date_row -%}
  201.     {% set force_error = true %}
  202.     {{- block('form_row') }}
  203. {%- endblock date_row %}
  204.  
  205. {% block time_row -%}
  206.     {% set force_error = true %}
  207.     {{- block('form_row') }}
  208. {%- endblock time_row %}
  209.  
  210. {% block datetime_row -%}
  211.     {% set force_error = true %}
  212.     {{- block('form_row') }}
  213. {%- endblock datetime_row %}
  214.  
  215. {% block checkbox_row -%}
  216.     <div class="form-group{% if not valid %} has-error{% endif %}">
  217.         {{- form_widget(form) -}}
  218.         {{- form_errors(form) -}}
  219.     </div>
  220. {%- endblock checkbox_row %}
  221.  
  222. {% block radio_row -%}
  223.     <div class="form-group{% if not valid %} has-error{% endif %}">
  224.         {{- form_widget(form) -}}
  225.         {{- form_errors(form) -}}
  226.     </div>
  227. {%- endblock radio_row %}
  228.  
  229. {# Errors #}
  230.  
  231. {% block form_errors -%}
  232.     {% if errors|length > 0 -%}
  233.     {% if form.parent %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %}
  234.     <ul class="list-unstyled">
  235.         {%- for error in errors -%}
  236.             <li><span class="glyphicon glyphicon-exclamation-sign"></span> {{ error.message }}</li>
  237.         {%- endfor -%}
  238.     </ul>
  239.     {% if form.parent %}</span>{% else %}</div>{% endif %}
  240.     {%- endif %}
  241. {%- endblock form_errors %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement