내가 심포니 2 형태 'PersonType', 주어진 사람의 아이들을지도해야 PersonType
수집 필드가 만들려고 해요.Symfony2 양식 FormType 자체 수집
그리고이 오류를 받고 있어요,
여기{"message":"unable to save order","code":400,"errors":["This form should not contain extra fields."]}
내 Person
실체이며,
class Person
{
private $id;
/**
* @ORM\OneToMany(targetEntity="Person", mappedBy="parent", cascade={"persist"})
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity="Person", inversedBy="children")
* @ORM\JoinColumn(name="orderitem_id", referencedColumnName="id", nullable=true)
*/
private $parent;
}
그리고 내 유형
, 는class PersonType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id')
->add('children', 'collection', array(
'type' => new PersonType()
))
;
}
는 UPDATE : 나는 보았다 문제는 옵션 때문이었다 :
'allow_add' => true,
'by_reference' => false
은 유형이 아니므로 삽입 할 때 양식이 나타나지 않고 페이지가 오류없이 중단되므로 삭제했습니다./
누군가가 이미 같은 문제에 직면 하는가 :
내가이 오류로 인해 매우 혼란 스러워요, 사람들은 아이를 가질 수없는 이유는 무엇입니까? (자체 이상 중첩 된 formType) ACUTALLY
: 여기에 설명 된 것처럼 내가 처음에이 마지막을 삽입 PersonchildrenType 내 personType을 복제했습니다 ...
(감사 편집을 위해, 나는 우선 또 다른 양식을 삽입 할 – pbenard
) ^^ 영어 매우 가난 해요,하지 동일 하나, 내가 completly 틀렸다면 당신이 뭔가를 이해하지 못하는 경우에 저에게 또는 그 자체로. 그리고 그것이 효과가 있는지보십시오. 다른 –
한이 사건에 대해 http://symfony.com/doc/current/cookbook/form/form_collections.html하지만, 아무것도 : 그것은 완벽하게 작동, 나는 문서를 읽었습니다. – pbenard