I try to create OneToMany association in my Creation entity.
Creation
class Creation
{
// ...
/**
* @ORM\OneToMany(targetEntity="App\Entity\Categorie", cascade={"persist"}, mappedBy="creation")
*/
private $categories;
// ...
}
CreationType
class CreationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('description')
->add('categories', EntityType::class, array(
'class' => 'App\Entity\Categorie',
'choice_label' => 'label',
'multiple' => true,
));
}
}
Now, I want display my Categories in my twig template :
{% for categorie in creation.categories %}
{{ categorie.label }}
{% endfor %}
I have this error, whereas I can display in dump this creation :
An exception has been thrown during the rendering of a template ("Notice: Undefined index: creation").
Someone can help ? Thanks