Thanks for putting together multimodelform. I got it set up and working and it is a huge help but confused about a simple aspect of it.

Using the example group::member that you have posted I have set up group.id as INT with Auto Increment and then formed a relation from member.groupid to group.id and changed my widget('ext.multimodelform.MultiModelForm',array( to match.

On my form I have Tile, Firstname, Lastname, Member Since as expected but there is also labels for ID and GroupId below them.

What do I need to modify to remove these labels from attributes where I am not collecting any data in the form? I understand how to handle all of this in a normal form but having problems making sense of the logic in your extension.

Hi again Joblo,
I was wondering if you had an example of using this with 3 or more forms?

Extending from your Group::Member example if there was a relationship Member::Profile how could I get the Profile form elements to also show up on the Group form? In my app (using my tables of course), I have used multimodelform to create forms for both Group::Member and Member::Profile but I am assuming I need to form some arrays with actionCreate and actionUpdate of the GroupController to make this happen to have Profile elements directly on the Group form, correct? I have tried a few different things and even tried pulling the logic from what qiang had written here. Anyways wondering if you have an example.

Sorry, there's no example for 3 or more forms.
But it works.
In a project I use an array of multimodelforms to render into a form (database is mongoDB).

For the profile you have to place a second multimodelform widget with another id and own validatedItems.
In the controller you have to handle extra validate / validatedItems / deleteItems.
It's similar to the wike-doc from qiang.

Sorry, there's no example for 3 or more forms.
But it works.
In a project I use an array of multimodelforms to render into a form (database is mongoDB).

For the profile you have to place a second multimodelform widget with another id and own validatedItems.
In the controller you have to handle extra validate / validatedItems / deleteItems.
It's similar to the wike-doc from qiang.

Hope the helps.

Ok I worked through it now. I had a problem with my relationships. I now have multiple forms displaying but can't fully test create and update until I clear up some things in my db.

I have extend the Multi model form extension to support File Upload field.
Currently, you can only use 'type' => 'file' in your form config to add an upload field to your dynamic form.
I'll try with CMultiUpload widget later.

When an error occurs on a form that form is then copied and placed under the original one and is blanked out. Can I change this behavior to not create a copied instance of the form and just use the original form to reinput their data?

Sure I want the user to be able to correct their information but not through the second copy of the model (Member). I want them to be able to correct directly in the place where the mistake occurred. In the case above in the red shaded box of Firstname.

I have been trying to modify you method run() even before posting my original question but can't seem to be getting anything working.

Ok not sure what I am not understanding here. With relCopy does the behavior I mentioned have to happen? I have been chasing my tail trying to figure out the behavior but am not getting anywhere. I would appreciate any help.

When an error occurs on a form that form is then copied and placed under the original one and is blanked out. Can I change this behavior to not create a copied instance of the form and just use the original form to reinput their data?

I am not sure if the method run() is causing this?

As I understand, if the validation failed, you don't want the Multi model form to add another blank form after the last subform. You just like the form to appear like it is, before click the "Save" button, right?

Unfortunately, this is not possible. The extension automatically create a sub form with the config provided, as a source for jQuery Relcopy to create new ones when click the Add Item.

Using CForm 's showErrorSummary setting (read Yii api about this), you can make the subform display its own error. By default, the extension return the error to Member model, so when validation failed, there is only one error Summary display on top of the form.

Maybe I will add this feature configurable in the widget.
But in my opinion a user should be able to add more items also when other fields show errors.
And the AddItem link needs a empty CopyTemplate to clone...

dinhtrung and Joblo,
Thanks for the response. Maybe I didn't fully appreciate the purpose of this extension. In my app I have changed my user forms to a more basic approach but can still utilize the functionality of this app in my admin forms.

I'm having some issues with checkboxes. It appears the jQuery addon doesn't copy the hidden field Yii generates so that an unchecked box is 0 rather than blank.
I fixed it for myself by adding a custom validation rule that sets the field to 0 if it is null, but it would be better if the hidden field was copied. (It works right for each row generated server side, just not for extra rows added client side.)