EmbedForm et many to many
(Re)Bonjour. Voici le schéma de ma BDD. J'ai mis en place un embedForm pour les catégories lorsque j'ajoute un nouveau post.
//dans PostForm.class.php
$this->embedForm('category', new CategoryForm());
Lors de l'ajout de ce post, si je ne choisi aucune catégorie déjà présente je choisi donc grâce à l'embed de pouvoir ajouter une catégorie a ce post. Quand je valide le formulaire, mon post est bien inséré en bdd ainsi que la catégorie dans la BDD, cependant rien est impacté dans ma table PostCategory pour associer ma catégorie à mon post. Je suppose que symfony a du quelque chose pour faire cela, mais je ne trouve pas comment. Merci à vous.
Post:
  actAs:
    Sluggable:
      unique: true
      fields: [title]
      canUpdate: true
      notnull: true
  columns:
    id:
      type: integer(8)
      primary: true
      notnull: true
      autoincrement: true
   .....
  relations:
    PostCategories:
      class: Category
      refClass: PostCategory
      local: post_id
      foreign: cat_id
      foreignAlias: Posts
Category:
  actAs:
    Sluggable:
      unique: true
      fields: [name]
      canUpdate: true
      notnull: true
  columns:
    id:
      type: integer(8)
      primary: true
      notnull: true
      autoincrement: true
    name:
      type: string(32)
      notnull: true
    description:
      type: clob
    parent:
      type: integer(8)
      notnull: true
      default: 0
    count:
      type: integer(4)
      notnull: true
      default: 0
PostCategory:
  columns:
    post_id:
      type: integer(8)
      primary: true
      notnull: true
    cat_id:
      type: integer(8)
      primary: true
      notnull: true
  relations:
    Post:
      class: Post
      local: post_id
      foreign: id
      foreignAlias: PostCategories
      onDelete: CASCADE
    Category:
      class: Category
      local: cat_id
      foreign: id
      foreignAlias: PostCategories
      onDelete: CASCADE
Réponses apportées à cette discussion
Le schéma de ma BDD se trouve ici http://img41.imageshack.us/img41/9355/bdd.png