Slide 59
Slide 59 text
Problem 3: mix both fields
class PostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
// ...
->add('current_tags', EntityType::class, [
'property_path' => 'tags',
'class' => Tag::class,
'choice_label' => 'name',
'multiple' => true,
])
->add('new_tags', CollectionType::class, [
'entry_type' => TagType::class,
'entry_options' => [
'empty_data' => function(FormInterface $form) {...},
],
'by_reference' => false,
'allow_add' => true,
'mapped' => false,
])
;
}
}