{% macro getFieldData(lines, form) %}
    {% set fieldData = {} %}

    {% if lines is not iterable %}
        {% set lines = [] %}
    {% endif %}

    {% for line in lines %}
        {% set fieldData = fieldData|merge({(line): form_widget(form.lines.vars.prototype[line])}) %}
    {% endfor %}

    {% for index, line in form.line %}
        {% set fields = {} %}

        {% for field in line.children|keys %}
            {% set fieldValue %}
                {% set error = form_errors(line[field]) %}

                {% if error|trim is not empty %}
                    <div class="form-group has-error">
                        {{ form_widget(line[field]) }}
                        {{ error|raw }}
                    </div>
                {% else %}
                    {{ form_widget(line[field]) }}
                {% endif %}
            {% endset %}

            {% set fields = fields|merge({(field): ''~fieldValue}) %}
        {% endfor %}

        {% set formData = formData|merge({(index) : fields}) %}

        {% do line.setRendered() %}
    {% endfor %}

    {{ fieldData }}
{% endmacro %}
