symfony - Show data in a table using twig -


i have problem, code :

{% order in afilteredigdetails %}     {% if order.availability == 0 %}         <tr>              <td colspan="3" style="background: #ff0000;color:#ffffff">available</td>          </tr>         <tr>             <td>                 {{ order.gift_id }}             </td>             <td>                 {{ order.idm }}             </td>             <td>                 {{ order.email }}             </td>         </tr>     {% else %}         <tr>             <td colspan="3" style="background: #0000ff;color:#ffffff">unavailable</td>         </tr>         <tr>             <td>                 {{ order.gift_id }}             </td>             <td>                 {{ order.idm }}             </td>             <td>                 {{ order.email }}             </td>         </tr>     {% endif %} {% endfor %} 

all works fine, problem if have multiple order.availability == 0 each row have in top <tr> background : #ff0000; can me please? thx in advance. have idea? me please!!!!!!!

i found solution :

{% if afilteredigdetails %}                 {% order in afilteredigdetails %}                     {% if order.availability == 0 %}                     {% set counter_unavail = ( counter_unavail | default(0) ) + 1 %}                     {% if counter_unavail == 1 %}                     <tr>                          <td colspan="3" style="background: #ff0000;color:#ffffff">unaivailable</td>                      </tr>                     {% endif %}                     <tr>                         <td>                             {{ order.gift_id }}                         </td>                         <td>                             {{ order.idm }}                         </td>                         <td>                             {{ order.email }}                         </td>                     </tr>                     {% elseif order.availability == 1 %}                         {% set counter_avail = ( counter_avail | default(0) ) + 1 %}                         {% if counter_avail == 1 %}                         <tr>                             <td colspan="3" style="background: #0000ff;color:#ffffff">available</td>                         </tr>                         {% endif %}                         <tr>                             <td>                                 {{ order.gift_id }}                             </td>                             <td>                                 {{ order.idm }}                             </td>                             <td>                                 {{ order.email }}                             </td>                         </tr>                     {% endif %}                 {% endfor %}             {% else %}                 <td colspan="3">---</td>             {% endif %} 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -