doctrine2 - Symfony Doctrine Many2Many relationship works only one way -


i'm developing project management system symfony2. have project can have 1 or more categories (many2many relation). after generating 2 entities, forms , controllers symfony, can create new category , assign projects (categoryproject/1/edit) can't oposit, means can't assign categories project in project edit form (every time when choose categories , press update choosen fields white again). how possible? here code:

the project entity: dbe\ddbundle\entity\project:

manytomany: categoryproject:   targetentity: dbe\ddbundle\entity\categoryproject   mappedby: project 

the categoryproject doctrine:

  manytomany: project:   targetentity: dbe\ddbundle\entity\project   inversedby: categoryproject   jointable:     name: projecttocategoryproject     joincolumns:       category_project_id:         referencedcolumnname: id         nullable: false     inversejoincolumns:       project_id:         referencedcolumnname: id         nullable: false 

here query symfony toolbar: why there questionmark?

    select    t0.id id1,    t0.name name2,    t0.description description3     categoryproject t0    inner join projecttocategoryproject on t0.id = projecttocategoryproject.category_project_id     projecttocategoryproject.project_id = ? 

and here add function:

    /**  * add categoryproject  *  * @param \dbe\ddbundle\entity\categoryproject $categoryproject  * @return project  */ public function addcategoryproject(\dbe\ddbundle\entity\categoryproject $categoryproject) {       $categoryproject->addcategory($this);     $this->categoryprojects[] = $categoryproject;     // $this->categoryproject[] = $categoryproject;      return $this; } 

thanks in advance guys help!

here solution, made error in reasoning :-)

    $entity = $em->getrepository('dbeddddbundle:project')->findonebyid($id);     $comment = $em -> getrepository('dbedddddbundle:comment') -> findbyproject($entity); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -