Multimodel In Same Form And In A Grid

I have a model "TamanhoPizza" which have a foreign field "pizzaId", which refers to a model "Pizza", a field "diameter", a field "name", etc.

When I’m creating a Pizza i have the pizza informations, like name, and the size informations. Attached is my screen section where I want to add sizes for the pizza.

My gridview have a dataprovider of models "TamanhoPizza".

What I want is when I fill the inputs and click on "Adicionar"(add) I want to add a new line to the grid and be able to use the information on the grid while saving the pizza in the server size.

How can I achieve that?

If i was not clear, please ask for information.

Today i’m adding the lines (with some hidden columns) with JQuery and before I submit the form I go through each line of the grid, create a new object, add the object into an array, then I use JSON.stringify(array) and put the value in a hidden field.

Then in the server side I use $objects = json_decode($_POST[‘jsonArrayObjects’]) to get the values. It works, but I don’t think that is a good approach.


I needed something like that too … but it is not easy to find an answer to the problem…