Hi,
First, i'm new to symfony 2 and Sonata, so it's maybee a dumb question.. But i've searched without finding an answer.
I've got 2 Entities, User and Article, Many users can collaborate on many articles.
in User :
/**
* Bidirectional - Many users have Many articles (OWNING SIDE)
*
* @ORM\ManyToMany(targetEntity="Article", inversedBy="userArticles")
* @ORM\JoinTable(name="user_articles",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="article_id", referencedColumnName="id")}
* )
*/
private $articles;
and in Article :
/**
* Bidirectional - Many articles are authored by many users (INVERSE SIDE)
*
* @ORM\ManyToMany(targetEntity="User", mappedBy="articles")
*/
private $userArticles;
When i try to add the field in SonataAdminBundle, like this :
$formMapper->add('userArticles', 'sonata_type_collection', array(
'by_reference' => false
), array(
'expanded' => true,
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'name'
));
I've got an error :
INVALID MODE : s50436e8e06884_userArticles - type : sonata_type_collection - mapping : 8
What did i forgot or did wrong ?
While i'm here.. ;)..
I'm trying to add Medias to the Article, like this :
/**
* @var ArrayCollection $media
*
* @ORM\OneToMany(targetEntity="Application\Sonata\MediaBundle\Entity\Media", mappedBy="article")
*/
private $media;
This works in the admin with this code :
$formMapper->add('media', 'sonata_type_collection', array(
'by_reference' => false
), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'name',
'link_parameters' => array()
));
but when i click the "add" button, i've got an error (ajax) :
Property "media" is not public in class "Vince\CmsBundle\Entity\Article
", nor could adders and removers be found based on the guessed singulars: Medion, Medium (provide
a singular by suffixing the property path with "|{singular}" to override the guesser). Maybe
you should create the method "setMedia()"
And i don't have the list of Media already in DB. I've got 2 Images, added with SonataMediaBundle
Hmm.. I must have forgot something, but what ? Thanks for any help.