vendredi 18 septembre 2015

Problems on listing

My sistem has two related tables called material and items_budget. The second table has a form that lists the name of each material as a checkbox, followed by two more input, one for is quantity and the other one for its price. Here's the code:

{% for material in materials %}
    <div class="checkbox">
        <label>
            <input class="itemsbudget_material" type="checkbox" name="cdg_itemsbudget_type[material][]" value="{{ material.id }}"> {{ material.name }} - 
        </label>
        <input class="itemsbudget_quantity" type="text" name="cdg_itemsbudget_type[quantity][]" placeholder="Qtd" size="5"/>x - R$
        <input class="itemsbudget_price_hidden" type="hidden" value="{{ material.price }}"/>
        <input class="itemsbudget_price" type="text" name="cdg_itemsbudget_type[price][]" value="0" size="5" readonly/>
    </div>
{% endfor %}

There is a trigger that is triggered when a new data is inserted into items_budget, which function is to subtract from the current quantity of the selected material the quantity specified in the form.

The problems is that the trigger's function only works correctly with the first register in the material table, with the rest, the quantity field always returns NULL. According to the code above, I tried to proceed by putting brackets at the end of the name attribute, but doing this way the form page is only refreshed and no data is inserted into items_budget. Is there another way to list entities in Symfony2? Thank you!




Aucun commentaire:

Enregistrer un commentaire