Symfony 6 - how to use CollectionType Field

Viewed 18

Config : Symfony 6.1, PHP 8.1.4, Xampp

I have 3 entities: Carousel, Picture and CarouselPicture.

CarouselPicture is the entity created to make a join table in the ManyToMany relationship with attribute that exists between Carousel and Picture. For each entity there is a FormType.

In my CarouselType (the form for Carousel), I would like to dynamically add fields from CarouselPictureType.

After reading the docs, I understand that you can add a CollectionType... except I can't get it to work.

I probably missed something somewhere but I can't find it.

What I did (cf CarouselType) does not return an error but does not create the fields in question as can be seen below : https://i.stack.imgur.com/g0PUT.png

Here are the files involved in the problem

CarouselType : https://sharemycode.io/c/6ff7150

CarouselPictureType : https://sharemycode.io/c/f6edfab

Entity Carousel : https://sharemycode.io/c/a10ffac

Entity CarouselPicture https://sharemycode.io/c/97021c7

The Twig view of the Carousel form (in the comment an illustration of the output I would like to obtain) : https://sharemycode.io/c/85235bf

0 Answers
Related