0
FosUserBundle - >重寫ProfileTypeForm.phpSymfony3實體型不起作用
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',
));
}
MyProfileTypeForm.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');
}
));
}
錯誤代碼:
無論是財產 '省' 也不是一個的方法getProvince()
,province()
,isProvince()
,hasProvince()
,__get()
存在並在012類公共訪問。
Entity\LocationProvince
是使用控制檯和數據庫更新創建的,架構已創建。
Province
刪除時工作正常。
哇,我想這將是這麼簡單,謝謝 –
很高興它的工作! –