2014-12-22 2 views
0

Symfony 2.6.1을 사용하고 있습니다.Sonata Admin에서 m2m 관계를 구성하는 방법은 무엇입니까?

엔티티 구성 : http://pastebin.com/rMkYHjkE

관리 클래스 :

내가 선택한 개체 편집하려고
class PlaceAdmin extends Admin 
{ 
    // Fields to be shown on create/edit forms 
    protected function configureFormFields(FormMapper $formMapper) 
    { 
     $formMapper 
      //other fields 
      ->add('types', 'collection', array(
       'type'   => new PlaceType, 
       'allow_add' => true, 
      )); 
     ; 
    } 
    //other stuff 
} 

:

유형 "문자열의

예상 인수, 심포니 \ 구성 요소 \ 양식 \ ResolvedFormTypeInterface 또는 Symfony \ Component \ Form \ FormTypeInterface ", "Syloc \ Bundle \ GooglePlacesBu ndle \ 엔티티 \ PlaceType는 "the docs에서

답변

1

을 제공 :

이이 컬렉션의 각 항목에 대한 필드 유형 (예를 들어, 텍스트, 선택 등). 예를 들어 이메일 주소 배열을 가지고 있다면 이메일 유형을 사용합니다. 다른 양식의 콜렉션을 임베드하려면 양식 유형의 새 인스턴스를 작성한 후이 옵션으로 전달하십시오. 당신은 collection 양식 유형에 대한 엔티티 유형을 정의하지

class PlaceAdmin extends Admin 
{ 
    // Fields to be shown on create/edit forms 
    protected function configureFormFields(FormMapper $formMapper) 
    { 
     $formMapper 
      //other fields 
      ->add('types', 'collection', array(
       'type'   => 'text', 
       'allow_add' => true, 
      )); 
     ; 
    } 
    //other stuff 
} 

:

그래서 당신은 그런 짓을 할 것입니다. 아마도 도 찾고 싶지 만 collection이 아닌가? 또한 Entity 속성에서 자동으로 해결되므로이 양식 유형을 통해 하위 Entity 유형을 전달할 필요가 없습니다.

관련 문제