Answer the question
In order to leave comments, you need to log in
Why isn't the form collection showing up?
Hello.
Please tell me why the fields are not displayed?
The bottom line is that there would be dynamic forms.
Company.php
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="App\Entity\Curator", mappedBy="idcompany", cascade={"persist", "remove"})
*/
private $curators;
public function __construct()
{
$this->curators = new ArrayCollection();
}
/**
* @return Collection | Curator[]
*/
public function getCurators(): Collection
{
return $this->curators;
}
public function addProductField(Curator $curator): self
{
if (!$this->curators->contains($curator)) {
$curator->setIdcompany($this);
$this->curators[] = $curator;
}
return $this;
}
public function removeProductField(Curator $curator): self
{
if ($this->curators->contains($curator)) {
$this->curators->removeElement($curator);
}
return $this;
}
/**
* @var Company
*
* @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="curators")
* @ORM\JoinColumn(name="idcompany", referencedColumnName="id", onDelete="CASCADE")
*/
private $idcompany;
public function getIdcompany(): ?Company
{
return $this->idcompany;
}
public function setIdcompany(?Company $idcompany): self
{
$this->idcompany = $idcompany;
return $this;
}
/**
* @Route("/company/add", name="add_company")
*/
public function add()
{
$company = new Company();
$form = $this->createForm(CompanyType::class, $company);
return $this->render('company/add.html.twig', [
'form' => $form->createView(),
]);
}
->add('curators', CollectionType::class, [
'entry_type' => CuratorType::class,
'label' => false,
'by_reference' => false,
'prototype' => true,
'allow_add' => true,
'allow_delete' => true,
])
<ul>
{% for curator in form.curators %}
<li>{{ form_row(curator.curator_name) }}</li>
<li>{{ form_row(curator.email) }}</li>
{% endfor %}
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question