Post emergency Symfony questions for fast help... ...Or answer questions first & win prize money.

$4
Saving drops the relations that are not in the list

Hello!

First of all, sorry for my English. I'm a beginner in Sf, so...

I create a Customer Relationship Management System (as a beginner :D) and I have a problem with relations. There are companies and users in this system.

Some companies have a special flag, they are providers! It means, they can provide some services to 'plain' companies. Therefore I created a many-many relation between companies. In this case when i open the page of a company, I can see a company checkbox list, where I can check off which company is a provider for this company. I made a trick to remove non-provider companies from the list:

$choices = User::getProviders();
$this->widgetSchema['company_list'] = new sfWidgetFormChoice(array('choices' => $choices));


It works perfectly, only providers are shown in the list. BUT! User::getProviders() only returns with those providers where the user and the provider have a relation! It's a but difficult to understand so here is an example:

SUPERADMIN
When superadmin opens the page of XY company, User::getProviders() returns with ALL THE PROVIDERS:
PROV1
PROV2
PROV3
Superadmin check them off, so all three providers are checked.

USER
When a plain user opens the page of XY company, User::getProviders() returns with only one provider:
PROV1
It is checked, because superadmin checked it off. If now user click on save, PROV2, PROV3 relations will be deleted in the background.

How can I solve this? Every user should be able to modify only those relations that are shown in the list. If User::getProviders() doesn't return with PROV2, PROV3, the system shouldn't deal with them.

Thank you so much in advance!

saki | 07/28/10 at 5:10am | RSS Answers | Tags

(4) Possible Answers Submitted...

You must be logged in to view answers or answer this question.