form_social_layout.html.twig 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {% use 'form_div_layout.html.twig' %}
  2. {%- block form_row -%}
  3. {%- set row_attr = row_attr|merge({ class: row_attr.class|default(row_class|default('form-row')) }) -%}
  4. {{- parent() -}}
  5. {%- endblock form_row -%}
  6. {%- block widget_attributes -%}
  7. {%- set attr = attr|merge({ class: attr.class|default(widget_class|default('form-row-widget')) ~ (disabled ? ' ' ~ widget_disabled_class|default('form-row-widget-disabled')) ~ (errors|length ? ' ' ~ widget_errors_class|default('form-row-widget-error')) }) -%}
  8. {{- parent() -}}
  9. {%- endblock widget_attributes -%}
  10. {%- block form_label -%}
  11. {%- set label_attr = label_attr|merge({ class: label_attr.class|default(label_class|default('form-row-label')) }) -%}
  12. {{- parent() -}}
  13. {%- endblock form_label -%}
  14. {%- block form_help -%}
  15. {%- set help_attr = help_attr|merge({ class: help_attr.class|default(help_class|default('form-row-help')) }) -%}
  16. {{- parent() -}}
  17. {%- endblock form_help -%}
  18. {%- block form_errors -%}
  19. {%- if errors|length > 0 -%}
  20. <ul>
  21. {%- for error in errors -%}
  22. <li class="{{ error_item_class|default('form-error') }}">{{ error.message }}</li>
  23. {%- endfor -%}
  24. </ul>
  25. {%- endif -%}
  26. {%- endblock form_errors -%}
  27. {%- block choice_widget_expanded -%}
  28. {%- set attr = attr|merge({ class: attr.class|default('form-row-choice') }) -%}
  29. <div {{ block('widget_container_attributes') }}>
  30. {%- for child in form %}
  31. <div class="choice-children">
  32. {{- form_widget(child) -}}
  33. {{- form_label(child, null, { translation_domain: choice_translation_domain }) -}}
  34. </div>
  35. {% endfor -%}
  36. </div>
  37. {%- endblock choice_widget_expanded -%}
  38. {%- block checkbox_row -%}
  39. {%- set row_attr = row_attr|merge({ class: row_attr.class|default(row_class|default('form-row-checkbox')) }) -%}
  40. {%- set widget_attr = {} -%}
  41. {%- if help is not empty -%}
  42. {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
  43. {%- endif -%}
  44. <div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
  45. {{- form_errors(form) -}}
  46. <div class="inline-flex items-center">
  47. {{- form_widget(form, widget_attr) -}}
  48. {{- form_label(form) -}}
  49. </div>
  50. {{- form_help(form) -}}
  51. </div>
  52. {%- endblock checkbox_row -%}
  53. {%- block checkbox_widget -%}
  54. {%- set widget_class = widget_class|default('form-row-checkbox-element') -%}
  55. {{- parent() -}}
  56. {%- endblock checkbox_widget -%}
  57. {%- block radio_widget -%}
  58. {%- set widget_class = widget_class|default('form-row-radio-element') -%}
  59. {{- parent() -}}
  60. {%- endblock radio_widget -%}