data.html.twig 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. {% macro render_field(form, fields, scope) %}
  2. {% for index, field in fields %}
  3. {% set input = attribute(field, "input@") %}
  4. {% if input is null or input == true %}
  5. {% if form.value(scope ~ field.name) %}
  6. {% block field %}
  7. <div>
  8. {% block field_label %}
  9. <strong>{{ field.label|t|e }}</strong>:
  10. {% endblock %}
  11. {% block field_value %}
  12. {% if field.type == 'checkboxes' %}
  13. <ul>
  14. {% set use_keys = field.use is defined and field.use == 'keys' %}
  15. {% for key,value in form.value(scope ~ field.name) %}
  16. {% set index = (use_keys ? key : value) %}
  17. <li>{{ field.options[index]|e }}</li>
  18. {% endfor %}
  19. </ul>
  20. {% elseif field.type == 'checkbox' %}
  21. {{ (form.value(scope ~ field.name) == 1) ? "PLUGIN_FORM.YES"|t|e : "PLUGIN_FORM.NO"|t|e }}
  22. {% elseif field.type == 'select' %}
  23. {{ field.options[form.value(scope ~ field.name)]|e }}
  24. {% else %}
  25. {{ string(form.value(scope ~ field.name))|nl2br }}
  26. {% endif %}
  27. {% endblock %}
  28. </div>
  29. {% endblock %}
  30. {% endif %}
  31. {% else %}
  32. {% if field.fields %}
  33. {% set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope %}
  34. {{ _self.render_field(form, field.fields, new_scope) }}
  35. {% endif %}
  36. {% endif %}
  37. {% endfor %}
  38. {% endmacro %}
  39. {{ _self.render_field(form, form.fields, '') }}