What are the potential pitfalls of using the Collection Type in Symfony2 FormBuilder for one-to-many relationships?

One potential pitfall of using the Collection Type in Symfony2 FormBuilder for one-to-many relationships is that it can lead to performance issues when dealing with a large number of entities. To solve this, you can use the EntityType instead, which allows for lazy loading of entities and can improve performance.

$builder->add('relatedEntities', EntityType::class, [
    'class' => RelatedEntity::class,
    'choice_label' => 'name',
    'multiple' => true,
    'expanded' => true,
]);