I have this problem with SF2 when adding a form field of type "entity". This is my case:
This NetworkFormType contains Country field so in my NetworkFormType.php:
$builder->add('country', 'entity', [
'label' => $translator->trans('global.labels.country'),
'data_class' => 'MyBundle\Entity\Country',
'property' => 'name',
'choices' => $countries
])
I also have declared the public setters and getters in my Network entity. By the way, I registered my form as a service:
mybundle.form.network:
class: MyBundle\Form\NetworkFormType
tags:
- { name: form.type, alias: mybundle_form_network }
But it always results to:
Could not load type "entity"
Reference: entity Field Type
Anyone got an idea?
That is weird indeed.
According to this API documentation, EntityType
class is located within Doctrine Bridge
.
Packagist: https://packagist.org/packages/symfony/doctrine-bridge
Do you have it installed? Maybe you're not using full-stack Symfony?