First of all, sry for my English. I have some problem with embed forms, please help me!
This is big system, so I try to explain the situation shortly. There are users, partners (companies) and roles (ex. Manager, Developer, ...) in my system. There is a many-many connection between users and partners. The connection table is called LinkPartnerUser (fields: id, user_id, partner_id). There is a many-many connection between the LinkPartnerUser and Role objects (connection table: LinkPartnerUserRole, fields: linkpartneruser_id, role_id), so I can add a User to several partners with several roles. That's ok, it works fine.
<strong>What I want to do?</strong>
When I create a new User, I would like to create the LinkPartnerUser relation, too.
<strong>What's the problem?</strong>
I embed the LinkPartnerUser form on the user/new page, this way:
$linkpartneruser = new LinkPartnerUser();
$linkpartneruser->User = $this->getObject();
$linkpartneruserForm = new LinkPartnerUserForm($linkpartneruser);
It embeds the LinkPartnerUser form. I see one input field (partner_id) and the 'roles' checkbox list (many-many). After saving I realise that, it doesn't save the embed form's roles list (many-many relation). However it saves the partner_id field (I filled it in manually) I check the LinkPartnerUser relation this way:
If I try to change the existing relation, it works the same way I said before, I can change the partner_id fields, but it doesn't save the roles list, however If I create the connection with phpmyadmin manually in the db, the embed form can show the relations perfectly.
<strong>1. How can solve this problem?
2. If I use embedRelation, it show all the related objects. How can I show only one related object? I want to show only that relation where partner_id = 2. (I know that there is only one relation with partner_id=2)
3. Now I manually fill in the partner_id field in the embed form, however the User form has a field, that contains the partner_id value. How can I set the embed form's partner_id field during the saving process with the value of a field of the parent form?</strong>
Thank you so much in advance.
Please, give me answers, explanation, not only "general useful urls" ;)