Symfony 实体类型不起作用

Symfony3 entity-type not work

FosUserBundle -> 覆盖 ProfileTypeForm.php

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->remove('username');
    $builder->add('Profile', MyProfileTypeForm::class, array(
        'mapped' => true,
        'label' => false,
        'required' => true,
        'translation_domain' => 'FOSUserBundle',
    ));
}

我的ProfileTypeForm.php 文件:

public function buildForm(FormBuilderInterface $builder, array $options)
{
   ....
   $builder
       ->add('firstname', TextType::class, array(
                'label' => 'form.profile.firstname',
                'constraints' => array(
                    new NotBlank(),
                    new Length(array('min' => 3))
                )
            ))
       ->add('country', CountryType::class, array(
                'label' => 'form.profile.country',
                'preferred_choices' => array(
                    'EN'
                )
            ))
       ->add('province', EntityType::class, array(
                'class' => 'Panel\UserBundle\Entity\LocationProvince',
                'choice_label' => 'Province',
                'query_builder' => function (EntityRepository $em){
                    return $em->createQueryBuilder('l')
                        ->orderBy('l.name');
                }
            ));
}

错误代码:

既不是 属性 'Province' 也不是 getProvince()province()isProvince()hasProvince()、[=16= 中的任何一种方法] 在 class Panel\UserBundle\Entity\LocationProvince.

中存在并具有 public 访问权限

Entity\LocationProvince 已使用控制台和数据库更新创建,已创建架构。

Province 删除后工作正常。

改变这个:

->add('province', EntityType::class, array(
     'class' => 'AppBundle:LocationProvince',
     'choice_label' => 'Province',
     'query_builder' => function (EntityRepository $em){
          return $em->createQueryBuilder('l')
                ->orderBy('l.name','ASC');
     }
));

看看是否可行...