custom_theme.html.twig 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {% use "bootstrap_4_layout.html.twig" %}
  2. {% block form_row -%}
  3. {%- if compound is defined and compound -%}
  4. {%- set element = 'fieldset' -%}
  5. {%- endif -%}
  6. {%- set widget_attr = {} -%}
  7. {%- if help is not empty -%}
  8. {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
  9. {%- endif -%}
  10. <{{ element|default('div') }}{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
  11. {{- form_label(form) -}}
  12. {{- form_widget(form, widget_attr) -}}
  13. {{- form_help(form) -}}
  14. {% block form_label_errors2 %}{{- form_errors(form) -}}{% endblock form_label_errors2 %}
  15. </{{ element|default('div') }}>
  16. {%- endblock form_row %}
  17. {% block form_label -%}
  18. {% if label is not same as(false) -%}
  19. {%- if compound is defined and compound -%}
  20. {%- set element = 'legend' -%}
  21. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
  22. {%- else -%}
  23. {%- set label_attr = label_attr|merge({for: id}) -%}
  24. {%- endif -%}
  25. {% if required -%}
  26. {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
  27. {%- endif -%}
  28. {% if label is empty -%}
  29. {%- if label_format is not empty -%}
  30. {% set label = label_format|replace({
  31. '%name%': name,
  32. '%id%': id,
  33. }) %}
  34. {%- else -%}
  35. {% set label = name|humanize %}
  36. {%- endif -%}
  37. {%- endif -%}
  38. <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>
  39. {%- if translation_domain is same as(false) -%}
  40. {%- if label_html is same as(false) -%}
  41. {{- label -}}
  42. {%- else -%}
  43. {{- label|raw -}}
  44. {%- endif -%}
  45. {%- else -%}
  46. {%- if label_html is same as(false) -%}
  47. {{- label|trans(label_translation_parameters, translation_domain) -}}
  48. {%- else -%}
  49. {{- label|trans(label_translation_parameters, translation_domain)|raw -}}
  50. {%- endif -%}
  51. {%- endif -%}
  52. </{{ element|default('label') }}>
  53. {%- else -%}
  54. {%- if errors|length > 0 -%}
  55. <div id="{{ id }}_errors" class="mb-2">
  56. {{- form_errors(form) -}}
  57. </div>
  58. {%- endif -%}
  59. {%- endif -%}
  60. {%- endblock form_label %}
  61. {% block image_selector_widget -%}
  62. <div class="input-group{{ group_class|default('') }}">
  63. {{- block('form_widget_simple') -}}
  64. <div class="input-group-append">
  65. <button class="btn image-selector" type="button">Выбрать</button>
  66. </div>
  67. </div>
  68. {%- endblock image_selector_widget %}