I have two related tables called material and items_budget. In the second table's form, I am listing all the added materials as a checkbox, followed by two input, one for quantity and another one for price.
<div class="form-group">
{% 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 %}
</div>
I have a trigger for subtracting the items_budget's quantity value from material's current_quantity, but the issue I am facing is that if I add the brackets at the end of the name attribute, be it _type[material[]] or _type[material][], when I submit the form, the information is not added to the database and the form simply reloads, like pressing F5. If I remove the brackets, ONLY the FIRST register added in the material works, and the items_budget quantity, material and price columns return NULL for the other ones. What is wrong with it?
Aucun commentaire:
Enregistrer un commentaire