doctrine2 - Symfony2 Form with Doctrine Relationship Persistence Issue -
So I have 3 entities with their properties, a user with many users, one with each one There are institutions:
/ ** * @ORM \ table (name = "skills") * @ORM \ unit () * / class skill { / ** * @ORM \ column (name = "id", type = "integer") * @ORM \ Id * @ORM / Generatedview (strategy = "auto") * / personal $ id; / ** * @ORM \ column (name = "name", type = "string", length = 30, unique = true) * / private $ name; / ** * @ORM \ column (name = "active", type = "boolean") * @ wise boole * / private $ active = false; / ** * @ORM \ OneToMany (targetEntity = "UserSkill", mapped = "skill") * / personal $ userSkills; } / ** * @ORM \ Table (name = "user_skill") * @ORM \ unit () * / class UserSkill {/ ** * @ORM \ Id * @ORM \ ManyToOne (targetEntity = "User", inversedBy = "Skill") * @ wise user * / private $ user; / ** * @ORM \ Id * @ORM \ ManyToOne (TargetItity = "Skill", Inverted = "User Skills") * @ War Skills * / Private $ Skills; / ** * @ORM \ column (type = "integer") * @ wise integer * / private $ level = 0; } / ** * Advanced User Interface applied to Class User, * / StartupDriven \ UserBundle \ Entity \ User * * @ORM \ Table (name = "users") * @ORM \ entity (repositoryClass = "StartupDriven \ UserBundle \ Entity \ UserRepository") * \ Serializable {/ ** * @ORM \ OneToMany (targetEntity = "UserSkill", mapped = "user") * @ wise arrays selection / personal $ skill; }
They are created using 2 Symphony form objects that work wonderfully.
The problem is that when I go to continue these objects in the controller .... I get an error
$ form-> HandleRequest ($ request); If ($ form-> isValid ()) {/ ** * @ User user $ / $ user = $ form- & gt; GetData (); / ** * @ User user $ $ skill / * $ foreach ($ user- & gt; getSkills () $ userSkill) {// No update skills ... Only new if (! $ UserSkill- & gt; GetId ()) {// Skill Check Match Match if ($ matched_skill = $ em-> GetRepository ('StartupDrivenUserBundle: Skill') -> SearchObject (array ('name' = & gt; $ userSkill- & Gt; getName ()))) {$ userSkill- & gt; Setcuck ($ matched_skill); } And {// no matches Create new general skills $ em- & gt; Continues ($ userSkill- & gt; getSkill ()); // error occurs on the following line! $ Em- & gt; Flush (); } // user $ user skeleton-> Set user ($ user) set; // Keep user skills $ Em-> Continues ($ userSkill); $ Em- & gt; Flush (); }} $ Em- & gt; Continues ($ user); $ Em- & gt; Flush ();
Error message: A new unit was found through the relationship 'Startup Drain' userbundle \ unit \ user # skills' to cascade the running operations for the unit Was not configured for: StartupDriven \ UserBundle \ unit \ UserSkill @ 0000000053e8628e00007f7f2fd56e1f To resolve this problem: Either call EntityManager # persist () on this unknown entity or conceave @ Convertrate to this union in messaging @ManyToOne (.., cascade = {"persist"} ). If you did not know which issue caused the problem to apply the problem to the 'Startup Drainn'UserBundal \ Unit \ User Asil # You to String ()'.
I have tried every effort; Flush that I can think I have tried the cascade option above (which gives a different error that "User ID which is required for primary key rules" is not set) ... I feel completely lost Is that such a simple relationship ... where am I going?
Comments
Post a Comment