form_admin_fields.html.twig 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. {% extends 'SonataAdminBundle:Form:silex_form_div_layout.html.twig' %}
  8. {# Labels #}
  9. {% block generic_label %}
  10. {% spaceless %}
  11. {% if required %}
  12. {% set attr = attr|merge({'class': attr.class|default('') ~ ' required'}) %}
  13. {% endif %}
  14. {% if in_list_checkbox is defined and in_list_checkbox and widget is defined %}
  15. <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
  16. {{ widget|raw }}
  17. <span>
  18. {{ label|trans({}, sonata_admin.admin.translationDomain) }}
  19. </span>
  20. {{ required ? '*' : '' }}
  21. </label>
  22. {% else %}
  23. <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans({}, sonata_admin.admin.translationDomain) }} {{ required ? '*' : '' }} </label>
  24. {% endif %}
  25. {% endspaceless %}
  26. {% endblock %}
  27. {% block field_row %}
  28. {% if sonata_admin is not defined or not sonata_admin_enabled or not sonata_admin.field_description %}
  29. {{ parent() }}
  30. {% else %}
  31. <div class="clearfix{% if errors|length > 0%} error{%endif%}" id="sonata-ba-field-container-{{ id }}">
  32. {% block label %}
  33. {% if sonata_admin.field_description.options.name is defined %}
  34. {{ form_label(form, sonata_admin.field_description.options.name) }}
  35. {% else %}
  36. {{ form_label(form) }}
  37. {% endif %}
  38. {% endblock %}
  39. <div class="input sonata-ba-field sonata-ba-field-{{ sonata_admin.edit }}-{{ sonata_admin.inline }} {% if errors|length > 0 %}sonata-ba-field-error{% endif %}">
  40. {{ form_widget(form) }}
  41. {% if sonata_admin.field_description.help %}
  42. <span class="help-block sonata-ba-field-help">{{ sonata_admin.field_description.help }}</span>
  43. {% endif %}
  44. {% if errors|length > 0 %}
  45. <div class="sonata-ba-field-error-messages">
  46. {{ form_errors(form) }}
  47. </div>
  48. {% endif %}
  49. </div>
  50. </div>
  51. {% endif %}
  52. {% endblock field_row %}