checkbox.html.twig 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. {% extends "forms/field.html.twig" %}
  2. {% block label %}
  3. {% endblock %}
  4. {% block input %}
  5. {% set id = field.id|default(field.name) ~ '-' ~ key %}
  6. <div class="{{ form_field_wrapper_classes ?: 'form-input-wrapper' }} {{ field.size }} {{ field.wrapper_classes }}">
  7. <input
  8. {# required attribute structures #}
  9. name="{{ (scope ~ field.name)|fieldName }}"
  10. value="{{ value|join(', ') }}"
  11. type="checkbox"
  12. {% if value == true %} checked="checked" {% endif %}
  13. {# input attribute structures #}
  14. {% block input_attributes %}
  15. id="{{ id|e }}"
  16. {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
  17. {% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
  18. {% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
  19. {% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
  20. {% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
  21. {% if required %}required="required"{% endif %}
  22. {% endblock %}
  23. />
  24. <label style="display:inline;" class="inline" for="{{ id|e }}">
  25. {% if field.markdown %}
  26. {{ field.label|t|markdown(false) }}
  27. {% else %}
  28. {{ field.label|t|e }}
  29. {% endif %}
  30. {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
  31. </label>
  32. </div>
  33. {% endblock %}