How to use collection type in a step?
Hello! I would like to use collection type to my form to the third step because I need to add multiple previous job (WorkExperience entities) to the use who submits the form. I followed this guide https://symfony.com/doc/current/form/form_collections.html but so far without great success..
My questions are:
- Where should I declare my collection? (I mean in which formType.php) In the one of the first step or somewhere else? I need that it renders at third step
- In which enity should be declared and how? (it is oneToMany relation -one user many previousJobs-)
- Is there the possibility to save it when I hit the "next step button"?
-In buildForm () should I insert the formType at the first step or the step that I want the collection to be appeared?
$builder->add('previousjobs','App\Form\WorkExperienceType');
Below I am attaching the code that I use:
ApplicationType.php (Step 1)
$builder->add('previousjobs', CollectionType::class, array( 'entry_type' => WorkExperienceType::class, 'allow_add' => true, 'prototype' => true, 'prototype_data' => 'New Tag Placeholder', ))
@bump
Need the same operation but don't know how to work with it.
@bump