Hello folks.
I’ve got a funny template issue. Basically I want a form that returns multiple objects (the number of objects returned is undefined).
So one solution would be to retrieve something like that in serialized parameter: %{"products" => %{"101" => %{...}, "102" => %{...}, ...}}
(where the numbers are the ids of products).
Right now I use a form tag with option as: :products
. And inside the loop of each product, something like this for a field:
= number_input f, "#{product.id}][stock", value: product.stock
As you can see, the string "#{product.id}][stock"
looks weird but it works as expected because the name
attributes are generated like this : product[101][stock]
Do you see a better way for this trick?