I have problem with many-many mapping into forms.
Schema:
==
Ducks:
id:~
name:
Hunters:
id:~
name:
D_H:
id:~
duck_id: { type: integer, foreignTable: Hunters, foreignReference: id,
required: true }
hunter_id: { type: integer, foreignTable: Hunters, foreignReference:
id, required: true }
==
I want in HunterForm, multiselect, where i can select Ducks (by name).
I solve it for inserts as :
==HunterForm::configure
$c=new Criteria(); //for future
$this->widgetSchema['ducks'] = new sfWidgetFormPropelChoice
(array('model' => 'Ducks', 'multiple' => true,'criteria'=>$c));
==
and Save
==HunterForm::doSave
foreach($this->getValue('ducks') as $id_duck)
{
$dh= new DH();
$dh->setDuckId($id_duck);
$this->getObject()->addDH($dh);
}
parent::doSave($con);
==
But how do this for edit/update ? I mean both : 1. save method 2. some
load-selected-to-form-select-input method.
Where and how i must load $hunter->GetDHjoinsDucks() , that in form
select element some ducks was "preselected" ?
Or may be, i totaly on wrong way, is another pattern?
Help me plz.
--
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en.