CraueFormFlowBundle icon indicating copy to clipboard operation
CraueFormFlowBundle copied to clipboard

How to use collection type in a step?

Open mdimitris opened this issue 7 years ago • 2 comments

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', ))

mdimitris avatar Aug 08 '18 07:08 mdimitris

@bump

Need the same operation but don't know how to work with it.

grzegorz-stolarz avatar May 23 '19 10:05 grzegorz-stolarz

@bump

grzegorz-stolarz avatar May 31 '19 12:05 grzegorz-stolarz