On debugging / var_dumping through the code I have detected, that the issue with the checkboxes is not as easy I thought first :-(

The problem is to handle the count of the submitted values of the checkboxes.
For one cloned checkbox there can exists one (submitted by the hidden yii-attribute if not checked) or two values (hidden yii-attribute and the cloned checkbox) in the submitted attributes array.

So the count of the submitted values from cloned checkboxes never matches the count of the other attributes and the multimodelform::initItems code is wrong for this :-(

I need an idea first, how to handle checkboxes ... in js or the initItems code.

I tested this with CFormModel and it can work with it but needs some modifications in your form and MultiModelForm.php. The CFormModel doesn't initially have or inherit the primaryKey property and method so those need to be added to the form that is used. In addition the MultiModelForm needs to be modified to be able to read it...

Joblo! I had ton of problems getting the cloning to work with my wysiwyg editor, multiple instances but all toolbars sent
input etc to the first instance (thats there on load). And it was impossible to write anything in the "clones".

My solution was: I took the js code rendered by my editor widget and put it in a seperate file.

I created a tiny action in my controller, that only made a renderPartial on my seperate file.

I then used 'jsAfterClone'=>'$("#foo").load("/howto/eltre")', in the multimodelconfiguration.
and tada, it worked like a charm.

On debugging / var_dumping through the code I have detected, that the issue with the checkboxes is not as easy I thought first :-(

The problem is to handle the count of the submitted values of the checkboxes.
For one cloned checkbox there can exists one (submitted by the hidden yii-attribute if not checked) or two values (hidden yii-attribute and the cloned checkbox) in the submitted attributes array.

So the count of the submitted values from cloned checkboxes never matches the count of the other attributes and the multimodelform::initItems code is wrong for this :-(

I need an idea first, how to handle checkboxes ... in js or the initItems code.

Yeah, that is what I was looking at.
The only way I could figure out to fix it would be to assign array indexes (just like you do for when things are already set) to everything. I think that would require several new pieces in your serverside and clientside JS.

Here is my idea:
1. Serverside: Use the existing count variable for the existing rows but increment it by 1 and set that is the new row
2. Serverside: Echo a new variable for JS called nextRowCount (for it to use as the index of the next row)
3. Clientside: Have the JS grab the nextRowCount when inserting new rows and increment it after each insert

Make since? It actually might not be that hard. It just depends how much effort it will take to make the global serverside and clientside variables.
You could even use a hidden form field for the client side one. (I would, however, make you JS code fallback to its normal way of not specifying an index if the field for next row index is missing though. That way it will be reverse compatible for people who are just using the JS portion.)

Hm, If i add related records when I update a main-model record the related records are saved properly,
but If I use the same form to add related records when I create a new main-model record only the main record is saved.

On debugging / var_dumping through the code I have detected, that the issue with the checkboxes is not as easy I thought first :-(

The problem is to handle the count of the submitted values of the checkboxes.
For one cloned checkbox there can exists one (submitted by the hidden yii-attribute if not checked) or two values (hidden yii-attribute and the cloned checkbox) in the submitted attributes array.

So the count of the submitted values from cloned checkboxes never matches the count of the other attributes and the multimodelform::initItems code is wrong for this :-(

I need an idea first, how to handle checkboxes ... in js or the initItems code.

Joblo, would it make sense to put the multimodelform code up on Github and then use the issue tracker to discuss this further? I've been looking at the checkbox issue myself for a project I'm working on. I'd be happy to help with it as well. Seems like the discussion of this issue might get lost in the other posts on this thread though ... I'm happy to post your latest multimodelform extension up if that would be helpful, but thought you might want to retain ownership ...

Yeah, that is what I was looking at.
The only way I could figure out to fix it would be to assign array indexes (just like you do for when things are already set) to everything. I think that would require several new pieces in your serverside and clientside JS.

Here is my idea:
1. Serverside: Use the existing count variable for the existing rows but increment it by 1 and set that is the new row
2. Serverside: Echo a new variable for JS called nextRowCount (for it to use as the index of the next row)
3. Clientside: Have the JS grab the nextRowCount when inserting new rows and increment it after each insert

Make since? It actually might not be that hard. It just depends how much effort it will take to make the global serverside and clientside variables.
You could even use a hidden form field for the client side one. (I would, however, make you JS code fallback to its normal way of not specifying an index if the field for next row index is missing though. That way it will be reverse compatible for people who are just using the JS portion.)

What if we were to shift to something more like Yii does for handling input data? I realize this could break backwards compatibility badly ... (could we have a flag for the widget that defines how this gets handled?)

Yii does things like this:

<input name="Contact[35][Phone]" id="Contact_35_Phone" type="text">

where this JS handles it like this:

<input name="Contact[Phone][]" id="Contact_Phone" type="text">

Would moving to the Yii system allow you to let Yii handle the attributes better for these types of inputs too? Just thinking out loud.

I've really tried to make texteditors to work for the textareas, My last solution did not work as I thought it did.

Somehow it seems to appear when adding a third element. I've walked thrue your code but 1200 rows and to be honest my knowledge is limited on how widgets work. Any thoughts on this? Which function and where should I try to modify?
What is the availeble variables?

first off, thank you very much for this awesome extension. I'm very new to yii and I would like to ask for anyone's help on how I could solve something I am not sure of with multimodelform:

I am currently working on a billing system. So basically there is a TOTAL AMOUNT DUE field in form and the value of this fied should change as you enter items for the billing items. I have the following fields for items:

quantity, amount, discount and total

As you enter quantity and amount the total box should be auto filled, and the sum of the value of the total boxes will be the value for TOTAL AMOUNT DUE field

How can i achieve this with multimodelform and yii. Thank you very much.

--------------
UPDATE:
I was able to do the computations already thru onchange event, the only problem is the javascript is not being run if there is just one row of fields for the items.. it will only start computing once I added a new row. Please help... thank you very much.

I'm facing some issues after using the MultiModelForm. In the base form, i have many MultiModelForm's rendering.
Problem:
The form values for MultiModelForm's fields are not changing if the validation is failed. After debugging I have found the bug.

I am using MultiModelForm to render forms of different datatype for the same field. So the name of these attributes across multiple models is same due to which validation is failing.

Hi,
I don't think this is a MMF issue, but I didn't know where else to post this..

I have one last piece and I think my form will be complete. I want to put the multimodelform into a cJuiTabs.
When I put the widget into the tab, It doesn't put it in the tab, but above it.
Can someone point me in the right direction?