Note that there are some explanatory texts on larger screens.

plurals
  1. POsymfony many to many in embedded form
    primarykey
    data
    text
    <p>I have a problem with embbed form from Model which has many to many relation. The embedded form will save the model correctly but will not save many to many relations.</p> <p>Example:</p> <p>Schema.yml:</p> <pre><code>Mother: columns: name: type: string(80) Color: columns: name: type: string(80) Child: columns: mother_id: type: integer name: type: string(80) relations: Mother: class: Mother local: mother_id foreign: id type: one onDelete: cascade foreignType: one foreignAlias: Children FavoriteColors: class: Color refClass: ChildColor local: child_id foreign: color_id onDelete: cascade foreignAlias: Children ChildColor: columns: child_id: type: integer color_id: type: integer </code></pre> <p>Then I just modify MotherForm.class.php:</p> <pre><code>class MotherForm extends BaseMotherForm { public function configure() { $this-&gt;embedForm('child', new ChildForm($this-&gt;getObject()-&gt;getChildren())); } } </code></pre> <p>and ChildForm.class.php:</p> <pre><code>class ChildForm extends BaseChildForm { public function configure() { unset($this['mother_id']); } } </code></pre> <p>I generate the module with doctrine:</p> <pre><code>php symfony doctrine:generate-module frontend mother Mother </code></pre> <p>Put some color data:</p> <pre><code>Color: Color_1: name: blue Color_2: name: red Color_3: name: green Color_4: name: purple </code></pre> <p>When I call /frontend_dev.php/mother/new I can add a new one, name of Mother and Child are updated but favorite color are never saved...</p> <p>If I add a relation between a color and a child with phpmyadmin and then /edit call. Then the right color is in the multiple select selected, but I can't edit it.</p> <p>Is it a bug from Symfony or should I do something else ?</p> <p>UPDATE: If I generate the module for the model Child. I can edit favorite colors but the form is not embedded anymore...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload