checkbox.html.twig 1.5 KB

1234567891011121314151617181920212223242526272829303132
  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. <label class="{{ form_field_checkbox_classes }}" for="{{ id|e }}">
  8. <input
  9. {# required attribute structures #}
  10. name="{{ (scope ~ field.name)|fieldName }}"
  11. value="{{ value|join(', ') }}"
  12. type="checkbox"
  13. {% if value == true %} checked="checked" {% endif %}
  14. {# input attribute structures #}
  15. {% block input_attributes %}
  16. id="{{ id|e }}"
  17. {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
  18. {% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
  19. {% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
  20. {% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
  21. {% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
  22. {% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
  23. {% endblock %}
  24. />
  25. <i class="form-icon"></i>
  26. {{ field.label|t|e }} {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
  27. </label>
  28. </div>
  29. {% endblock %}