I have a form for adding data into budget table. Its form has, in some part of it, a list of data from another table called material that simply lists the name of each material from the database. Beside of each item have two inputs field, one for quantity and one for price, that belong to budget table. Bellow is the code I wrote in my view:
{% for material in materials %}
<div class="col-lg-2">
{{ material.name }}
</div>
<div class="col-lg-10">
<input type="hidden" class="material-price" value="{{ material.price }}"/>
<input class="n-materials" type="number" size="15" name="cdg_budget_type[quantity]" value="0"/>
- R$
<input class="final-price" type="number" size="5" name="cdg_budget_type[price]" value="0" disabled/>
</div>
{% endfor %}
The hidden field is just used to multiply the quantity for price via JavaScript and printing it in the price field the total. That was the solution I found.
The field materials from budget was created as array type, so I need to know how to save this into the table, for example like this:
"Material A" = [
["quantity" => 12],
["price" => 124]
],
...