symfony2에서 작성한 양식이 있습니다.Symfony2 양식 오류 - 왜?
$builder->add('purchaseOrder','text');
$builder->add('product', 'entity', array(
'class' => 'WICProductBundle:Product',
'property' => 'name',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('p')
->where('p.account=?1')
->orderBy('p.name', 'ASC')
->setParameter(1,$this->account);
}
));
이 양식을 Twig에서 출력하고 제출하면 문제가 없습니다.
양식 작성기를 변경하여 양식을 제출하면 오류가 발생합니다.
$builder->add('purchaseOrder','text');
$builder->add('product','text');
나는 8 구매 주문 필드에 입력하고 I 제품의 옵션은 모두 잘 작동합니다 ... (65)의 값을 드롭 다운 선택 형태의 첫 번째 반복 ...
내가 65의 값으로 제품 필드를 입력 ... 그리고이 오류 얻을 8로 구매 주문 필드를 입력 양식의 두 번째 반복 :
Catchable Fatal Error: Argument 1 passed to WIC\PurchaseOrderLineItemBundle\Entity\PurchaseOrderLineItem::setProduct() must be an instance of WIC\ProductBundle\Entity\Product, string given, called in /Applications/MAMP/htdocs/symfonydev/vendor/symfony/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 538 and defined in /Applications/MAMP/htdocs/symfonydev/src/WIC/PurchaseOrderLineItemBundle/Entity/PurchaseOrderLineItem.php line 302
를 왜하고자했다에서 내 양식 휴식 매번 동일한 값인 "65"가 전달되면 드롭 다운을 텍스트 상자로 바꿔 넣으시겠습니까?
캐시를 지우셨습니까? –
예, 캐시가 아닙니다. 나는 처음에 "query_builder"가 제품에 대한 객체를 생성했다는 사실과 관련이 있다고 생각합니다. 그런 다음 객체를 더 이상 존재하지 않는 간단한 텍스트 필드로 변경했습니다. 텍스트 필드 밖으로 개체를 만드는 방법을 모르거나 심지어 가능합니다. – LargeTuna