Single Form With Multiple Model

Hello

I am newbie to yii and I have a problem, this is what happens …

tables thus handle information:

child

child-> person

child-> person-> phone

child-> parent

child-> parent-> people

(these last two are twice because there is one for mother and one for father)

what I need is not only calling several models in one view of a form, but using the models person not only to save the info of the child but also the parents in the same view …

Not sure what you want to do.

Please explain the table schemas.

If you don’t work with relations in your model or if you want two or more model separate in your controller or view you can do this:

in controller action:




$child = new Child();

$parent = new Parent();



table schema:

table child has a relation with table person

table child has a relation with table parent

table parent has a relation with table person

so i need a view with several person models

I used the yii extension wfrom to handle the forms you have requested.

http://www.yiiframework.com/extension/wform

I am also in a situation where i have multiple models and dependencies between the models.

model

model->submodel

model->submodel -> multiple participants

model->submodel -> multiple participants -> multiple efforts

and so on

everything was in one ajax form and should only be saved if everything is correct.

I really hope that Yii2 will also support this kind of forms, so that there is no dependency on extension which uses a “flaw” to set the submodel attributes. wform used the CActiveRecord::onUnsafeAttribute “error” to set the sub model attributes. And i didn’t like it that much so generate an “error” submission to get what i wanted.

But i didn’t find any other solution.