Inserting Related Records

hello there , this is my first post so please be lenient.

atached if the eer diagram,

in the client form i am adding a dropddown of different roles.

how can i insert the client in the client table and the association in the client_has_role table .

thank you.

Hi redam, welcome to the forum.

So this is a typical MANY_MANY relation.

Usually we create and save the client model first and get the id of the client. And then we save the client_has_role model, specifying the id of the client and the id of the role.

Yii doesn’t support the automated saving of the related objects out of the box, so you have to do it by yourself.

You may want to use some extension to automate the process.