radio.html.twig 1.2 KB

1234567891011121314151617181920212223242526
  1. {% extends "forms/field.html.twig" %}
  2. {% set originalValue = value %}
  3. {% set value = (value is null ? field.default : value) %}
  4. {% block input %}
  5. {% for key, text in field.options %}
  6. {% set id = field.id|default(field.name) ~ '-' ~ key %}
  7. <div class="radio {{ form_field_wrapper_classes }} {{ field.wrapper_classes }}">
  8. <label class="{{ form_field_radio_classes }}" for="{{ id|e }}">
  9. <input type="radio"
  10. value="{{ key|e }}"
  11. id="{{ id|e }}"
  12. name="{{ (scope ~ field.name)|fieldName }}"
  13. {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
  14. {% if key == value %}checked="checked" {% endif %}
  15. {% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
  16. {% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
  17. />
  18. <i class="form-icon"></i>
  19. {% if grav.twig.twig.filters['tu'] is defined %}{{ text|tu|raw }}{% else %}{{ text|t|raw }}{% endif %}
  20. </label>
  21. </div>
  22. {% endfor %}
  23. {% endblock %}