I haven't any example and I though I'll find it on this page.

So I tried something like that on your relationship

At start User and Level haven't any UserLevel so you can't embed
UserLevel form. You should build a new widget into your form and allow
multiple select

//UserForm.class.php
$this->widgetSchema['a_userlevel']  = new sfWidgetFormPropelChoice
(array('model' => 'Level', 'multiple' => true)); //use expanded
options to get a list of checkboxes
$this->validatorSchema['a_userlevel']   = new sfValidatorPropelChoice
(array('model' => 'Level', 'multiple' => true));

//then overide the doSave method:
protected function doSave($con = null)
{
        $user = $this->getObject();

        foreach($this->getValue('a_userlevel') as $id_level)
        {
                $userLevel = new UserLevel();
                $userLevel ->setIdLevel($id_level);
                $user->addUserLevel($userLevel);
        }

        parent::doSave($con);
}

I hope you have already found your answer.

DEY.

On May 7, 7:37 pm, Steve the Canuck <[email protected]> wrote:
> I should have titled this many-to-many.
>
> Basically all I'm looking for is an example of how to implement many
> to many relationships in forms.
>
> Thanks,
> Steve
>
> On May 7, 1:21 pm, Steve the Canuck <[email protected]> wrote:
>
> > Hi,
>
> > I am having some form troubles.  I have a select dropdown which allows
> > you select multiple options.  If you select two options, I want to
> > insert to records into the database.
>
> > Here is a simple representation of the tables:
>
> > User <--- UserLevel ---> Level
>
> > So, I use the UserLevelForm and select multiple level choices, this
> > seems to confuse symfony, as it seems the Form is bound to a single
> > UserLevel row, rather than 3.
>
> > Has anyone come across anything similar, and come up with a solution?
>
> > Thanks,
> > Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to