{% set countIteration = 1 %}{% set openFlag = 0 %} {% set closeFlag = 0 %} {% set makeGap = false %} {% for field in businessRulesData%} {# set prev and next fields #} {% if businessRulesData[loop.index] is defined %} {% set nextField = businessRulesData[loop.index] %} {% else %} {% set nextField = null %} {% endif %} {% if businessRulesData[loop.index-2] is defined %} {% set prevField = businessRulesData[loop.index-2] %} {% else %} {% set prevField = null %} {% endif %} {# update counter #} {% if countIteration == 1 and prevField is not null and prevField['control'] != "radio" and (field['visible']==1) and(field['control'] != "radio") %} {% set countIteration = 2 %} {% elseif countIteration == 2 and (field['visible']==1) and(field['control'] != "radio") %} {% set countIteration = 1 %} {% endif %} {# make gap #} {% if countIteration == 1 and (nextField is null or (nextField is not null and nextField['control'] == "radio") ) and (field['visible']==1) and(field['control'] != "radio") %} {% set makeGap = true %} {% elseif countIteration == 2 %} {% set makeGap = false %} {% endif %} {# open two rows? #} {% if countIteration==1 and field['visible']==1 and field['control'] != "radio" and ( nextField is not null and nextField['visible']!=0 ) and ( nextField is null or nextField['control'] != "radio" ) %} {% set openFlag = 1 %} {% else %} {% set openFlag = 0 %} {% endif %} {# close two rows? #} {% if countIteration==2 and field['visible']==1 and field['control'] != "radio" and ( prevField is not null and prevField['visible']!=0 ) and ( prevField is null or prevField['control'] != "radio" ) %} {% set closeFlag = 1 %} {% else %} {% set closeFlag = 0 %} {% endif %} {# open wrapper div #} {#{{ dump(countIteration) }} {{ dump(makeGap) }}#} {% if openFlag==1 or makeGap == true %} <div class="form__grid form__grid--md"> {% endif %} {% if (field.sectionName == sectionName) %} {% include 'forms/signup/_field-templates-list.html.twig' %} {% if makeGap == true %} <div class="form__field"></div> {% endif %} {% endif %} {# close wrapper div #} {% if closeFlag==1 or makeGap == true %} </div> {% set makeGap = false %} {% endif %} {% endfor %}