2016-06-08 3 views
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은 삭제시 원활하게 작동합니다.

답변

0

변경이 : 제대로 작동 다행이 작동하는지

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

참조 ...

+0

와우, 내가 그렇게 간단 할 거라고 생각은 당신에게 –

+0

감사합니다! –

관련 문제