I start learning sf2, pretty cool, for my problem I have two tables:
Media
/**
* @ORM\ManyToMany(targetEntity="Test\SiteBundle\Entity\Website", inversedBy="medias")
* @ORM\JoinTable(name="media_website")
private $websites;
and Website
/**
* @ORM\ManyToMany(targetEntity="Test\SiteBundle\Entity\Media", mappedBy="websites")
private $medias;
In my MediaType.php I have this:
$builder
->add('title')
->add('website', 'entity', array(
'class' => 'TestSiteBundle:Website',
'property' => 'name',
'query_builder' => function(WebsiteRepository $er)use($user_id) {
return $er->getMyWebsites($user_id);
},
'multiple'=>false))
finally, in the twig page I have this:
<div class="form-group">
{{ form_label(form.description, "Description", { 'label_attr': {'class': 'control-label col-md-2'} }) }}
<div class="col-md-5">
{{ form_widget(form.description, { 'attr': {'class': 'form-control'} }) }}
</div>
</div>
When I try to add a Media I have this error:
Neither the property "websites" nor one of the methods "setWebsites()", "__set()" or "__call()" exist and have public access in class "Test\SiteBundle\Entity\Media".
Any help ? and many thanks to you.