Guest User

Untitled

a guest
Dec 13th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. {% use 'form_div_layout.html.twig' %}
  2.  
  3. {% block form_start -%}
  4. {% set attr = attr|merge({class: (attr.class|default('') ~ ' ui form')|trim}) %}
  5. {{- parent() -}}
  6. {%- endblock form_start %}
  7.  
  8. {# Widgets #}
  9.  
  10. {% block form_widget_simple -%}
  11. {{- parent() -}}
  12. {%- endblock form_widget_simple %}
  13.  
  14. {% block textarea_widget -%}
  15. {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
  16. {{- parent() -}}
  17. {%- endblock textarea_widget %}
  18.  
  19. {% block button_widget -%}
  20. {% set attr = attr|merge({class: (attr.class|default('') ~ ' ui button')|trim}) %}
  21. {{- parent() -}}
  22. {%- endblock %}
  23.  
  24. {% block money_widget -%}
  25. {{- block('form_widget_simple') -}}
  26. {%- endblock money_widget %}
  27.  
  28. {% block percent_widget -%}
  29. {{- block('form_widget_simple') -}}
  30. {%- endblock percent_widget %}
  31.  
  32. {% block datetime_widget -%}
  33. {% if widget == 'single_text' %}
  34. {{- block('form_widget_simple') -}}
  35. {% else -%}
  36. {% set attr = attr|merge({class: (attr.class|default('') ~ ' inline fields')|trim}) -%}
  37. <div {{ block('widget_container_attributes') }}>
  38. {{- form_errors(form.date) -}}
  39. {{- form_errors(form.time) -}}
  40. {{- form_widget(form.date, { datetime: true } ) -}}
  41. {{- form_widget(form.time, { datetime: true } ) -}}
  42. </div>
  43. {%- endif %}
  44. {%- endblock datetime_widget %}
  45.  
  46. {% block date_widget -%}
  47. {% if widget == 'single_text' %}
  48. {{- block('form_widget_simple') -}}
  49. {% else -%}
  50. {% set attr = attr|merge({class: (attr.class|default('') ~ ' inline fields')|trim}) -%}
  51. {% if datetime is not defined or not datetime -%}
  52. <div {{ block('widget_container_attributes') -}}>
  53. {%- endif %}
  54. {{- date_pattern|replace({
  55. '{{ year }}': form_widget(form.year),
  56. '{{ month }}': form_widget(form.month),
  57. '{{ day }}': form_widget(form.day),
  58. })|raw -}}
  59. {% if datetime is not defined or not datetime -%}
  60. </div>
  61. {%- endif -%}
  62. {% endif %}
  63. {%- endblock date_widget %}
  64.  
  65. {% block time_widget -%}
  66. {% if widget == 'single_text' %}
  67. {{- block('form_widget_simple') -}}
  68. {% else -%}
  69. {% set attr = attr|merge({class: (attr.class|default('') ~ ' inline fields')|trim}) -%}
  70. {% if datetime is not defined or false == datetime -%}
  71. <div {{ block('widget_container_attributes') -}}>
  72. {%- endif -%}
  73. {{- form_widget(form.hour) }}{% if with_minutes %}:{{ form_widget(form.minute) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
  74. {% if datetime is not defined or false == datetime -%}
  75. </div>
  76. {%- endif -%}
  77. {% endif %}
  78. {%- endblock time_widget %}
  79.  
  80. {% block dateinterval_widget %}
  81. {{- block('form_widget_simple') -}}
  82. {% endblock dateinterval_widget %}
  83.  
  84. {% block checkbox_widget -%}
  85. <div class="ui toggle checkbox">
  86. {{ parent() }}
  87. {{- form_label(form, null, { widget: parent() }) -}}
  88. </div>
  89. {%- endblock checkbox_widget %}
  90.  
  91. {% block radio_widget -%}
  92. <div class="ui radio checkbox">
  93. {% set attr = attr|merge({class: (attr.class|default('') ~ ' hidden')|trim}) %}
  94. {{- form_label(form, null, { widget: parent() }) -}}
  95. </div>
  96. {%- endblock radio_widget %}
  97.  
  98. {% block range_widget %}
  99. <div class="ui star rating" data-rating="{{ form.vars.value }}" data-min-rating="{{ attr.min|default('1') }}" data-max-rating="{{ attr.max|default('4') }}"></div>
  100. <input type="hidden" value="{{ form.vars.value }}" name="{{ form.vars.full_name }}" id="{{ form.vars.id }}">
  101. <script>
  102. $(document).ready(function() {
  103. $('.ui.rating')
  104. .rating({
  105. minRating: {{ attr.min|default('1') }},
  106. maxRating: {{ attr.max|default('5') }}
  107. })
  108. .rating('enable')
  109. .rating('setting', 'onRate', function(value) {
  110. console.log(value);
  111. $('#{{ form.vars.id }}').val(value);
  112. })
  113. ;
  114. })
  115. ;
  116. </script>
  117. {% endblock %}
  118.  
  119. {# Labels #}
  120.  
  121. {% block form_label -%}
  122. {{- parent() -}}
  123. {%- endblock form_label %}
  124.  
  125. {% block choice_label -%}
  126. {{- block('form_label') -}}
  127. {% endblock %}
  128.  
  129. {% block checkbox_label -%}
  130. {{- block('checkbox_radio_label') -}}
  131. {%- endblock checkbox_label %}
  132.  
  133. {% block radio_label -%}
  134. {{- block('checkbox_radio_label') -}}
  135. {%- endblock radio_label %}
  136.  
  137. {% block checkbox_radio_label %}
  138. {# Do not display the label if widget is not defined in order to prevent double label rendering #}
  139. {% if widget is defined %}
  140. {% if required %}
  141. {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
  142. {% endif %}
  143. {% if label is not same as(false) and label is empty %}
  144. {%- if label_format is not empty -%}
  145. {% set label = label_format|replace({
  146. '%name%': name,
  147. '%id%': id,
  148. }) %}
  149. {%- else -%}
  150. {% set label = name|humanize %}
  151. {%- endif -%}
  152. {% endif %}
  153. {{- widget|raw }}
  154. <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
  155. {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
  156. </label>
  157. {% endif %}
  158. {% endblock checkbox_radio_label %}
  159.  
  160. {# Rows #}
  161.  
  162. {% block form_row -%}
  163. <div class="field{% if not valid %} error{% endif %}">
  164. {{- form_label(form) -}}
  165. {{- form_widget(form) -}}
  166. {{- form_errors(form) -}}
  167. </div>
  168. {%- endblock form_row %}
  169.  
  170. {% block button_row -%}
  171. {{- form_widget(form) -}}
  172. {%- endblock button_row %}
  173.  
  174. {% block choice_row -%}
  175. {{- block('form_row') }}
  176. {%- endblock choice_row %}
  177.  
  178. {% block date_row -%}
  179. {{- block('form_row') }}
  180. {%- endblock date_row %}
  181.  
  182. {% block time_row -%}
  183. {{- block('form_row') }}
  184. {%- endblock time_row %}
  185.  
  186. {% block datetime_row -%}
  187. {{- block('form_row') }}
  188. {%- endblock datetime_row %}
  189.  
  190. {% block checkbox_row -%}
  191. <div class="field{% if not valid %} error{% endif %}">
  192. {{- form_widget(form) -}}
  193. {{- form_errors(form) -}}
  194. </div>
  195. {%- endblock checkbox_row %}
  196.  
  197. {% block radio_row -%}
  198. <div class="field{% if not valid %} error{% endif %}">
  199. {{- form_widget(form) -}}
  200. {{- form_errors(form) -}}
  201. </div>
  202. {%- endblock radio_row %}
  203.  
  204. {# Errors #}
  205.  
  206. {% block form_errors -%}
  207. {% if errors|length > 0 -%}
  208. <div class="ui pointing red label">
  209. <i class="warning sign icon"></i>
  210. {%- for error in errors -%}
  211. {{ error.message }}
  212. {%- endfor -%}
  213. </div>
  214. {%- endif %}
  215. {%- endblock form_errors %}
Add Comment
Please, Sign In to add comment