无法确定媒体资源的访问类型

时间:2018-09-10 14:30:36

标签: php symfony doctrine-orm

我正在尝试创建带有实体集合的表单。 这是我的代码:

Colle实体:

about:
  summary: data['description']
  description: data['long_description']
  githash: {{ GIT_FULL_HASH }}

Polycopie实体:

 * @ORM\Table(name="colle")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({"colle"="Colle","colleQC"="ColleQC", "colleQR"="ColleQR"})
 */
class Colle
{
    /**
     * @var ArrayCollection
     * @ORM\OneToMany(targetEntity="Polycopie", mappedBy="colle", cascade={"persist", "remove"})
     */
     protected $polycopies;

public function __construct()
{
    $this->polycopies = new ArrayCollection();
}

    /**
 * @return ArrayCollection
 */
public function getPolycopies()
{
    return $this->polycopies;
}


/**
 * Add Polycopie
 *
 * @param Polycopie $polycopie
 * @return Colle
 */
public function addPolycopie(Polycopie $polycopie)
{
    $this->polycopies[] = $polycopie;

    return $this;
}

/**
 * Remove Polycopie
 *
 * @param Polycopie $polycopie
 */
public function removePolycopie(Polycopie $polycopie)
{
    $this->polycopies->removeElement($polycopie);
}
}

表格:

class Polycopie
{
    /**
     * @ORM\ManyToOne(targetEntity="Colle", inversedBy="polycopies", cascade={"persist"})
     * @ORM\JoinColumn(name="id_colle", referencedColumnName="id")
     */
     protected $colle;

     public function getColle(): ?Colle
{
    return $this->colle;
}

public function setColle(Colle $colle): self
{
    $this->colle = $colle;

    return $this;
}
}

PolycopieForm:

class MiseEnLigneFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->add('polycopies', CollectionType::class,
            ['label' => false,
                'label_attr' => ['class' => 'active'],
                'entry_type' => PolycopieFormType::class,
                'entry_options' => [
                    'data_class' => Polycopie::class],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false
            ]);
}

 public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(['data_class' => Colle::class]);
}
}

我一直收到此错误:

class PolycopieFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('nom', TextType::class, ['label' =>'Nom',
                                                 'label_attr' => ['class'=>'active']]);
}

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(['data_class' => Polycopie::class]);
}
}

我尝试清除缓存,但是它不起作用。

我进行了一些研究,这可能是因为缺少诸如getter或setter之类的东西,但是我找不到我的代码中缺少的东西。

0 个答案:

没有答案