data.txt.twig 742 B

1234567891011121314151617
  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. {%- set value = form.value(scope ~ (field.name ?? index)) %}
  6. {{- scope ~ (field.name ?? index) }}: {{ string(value is iterable ? value|json_encode : value|escape('yaml')) ~ "\r\n" }}
  7. {%- else %}
  8. {%- if field.fields %}
  9. {%- set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope -%}
  10. {{- _self.render_field(form, field.fields, new_scope) }}
  11. {%- endif %}
  12. {%- endif %}
  13. {%- endfor %}
  14. {%- endmacro %}
  15. {%- autoescape false %}
  16. {{- _self.render_field(form, form.fields, '') ~ "\r\n" }}
  17. {%- endautoescape %}