Как настроить тип формы с отношением многие ко многим?
Ниже конфигурации ...
Форма / тип / ProductType.php
$builder
->add('name')
->add('price')
->add('description', TextareaType::class)
->add('quantity')
->add('shopProductImages', EntityType::class, [
'class' => 'AppBundle:ShopProductImages',
'choice_label'=>'file',
'query_builder' => function (EntityRepository $repo) {
return $repo->createQueryBuilder('f')
->where('f.id > :id')
->setParameter('id', 1);
},
])
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => ShopProducts::class,
]);
}
Entity / ShopProducts.php
/**
* @ORM\Table(name="shop_products")
* @ORM\Entity
*/
class ShopProducts
{
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ShopProductImages", mappedBy="shopProducts")
*/
private $shopProductImages;
Entity / ShopProductImages.php
* @ORM\Table(name="shop_product_images")
* @ORM\Entity
*/
class ShopProductImages
{
/**
* @var string
*
* @ORM\Column(name="file", type="text", length=255, nullable=true)
*/
private $file;
/**
* @var \DateTime
*
* @ORM\Column(name="date_mod", type="datetime", nullable=true)
*/
private $dateMod;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ShopProducts", inversedBy="shopProductImages")
* @ORM\JoinTable(name="shop_product_images_has_shop_products",
* joinColumns={
* @ORM\JoinColumn(name="shop_product_images_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="shop_products_id", referencedColumnName="id")
* }
* )
*/
private $shopProducts;
... заканчивается ошибкой