问题描述
除了我的之前的问题.我现在想限制表单的输入字段.这样就只有供应商的输入字段,例如 id: 2 .而不是与订单相关的整个供应商集合.问题是,我在嵌入式集合中有一个嵌入式集合.我给我的第一个表单类型 $order .
In addition to my previous question. I now want to limit the input fields of my form. So that there are only input fields for the Supplier for example with the id: 2 . And not the whole collection of suppliers related to the Order. The problem is, that I have an embedded collection in an embedded collection. And i give $order to my first formtype.
$order = $this->getDoctrine()
->getRepository('AcmeAppBundle:PurchaseOrder')
$form = $this->createForm(new ProducedAmountOrderType(), $order);
我的问题是,我不能在集合的表单类型中使用查询构建器.那么,如何只显示一个供应商的输入字段,而不显示与实体相关的每个人的输入字段?
My problem is, that I can't use query builder in a form type for collections. So, how can I display only the input fields for one supplier and not for everyone related to the Entity?
推荐答案
我用这个 $order 查询解决了这个问题:
I solved it with this $order query:
$order = $this->getDoctrine()->getManager()->createQuery("
SELECT o, a , s
FROM AcmeAppBundle:PurchaseOrder o
JOIN o.purchaseOrders a
JOIN a.articleOrderReferences s
WHERE o.id = :orderId
AND s.supplier = :supplierId
AND s.amount > 0
")
->setParameter('orderId', $orderId)
->setParameter('supplierId', $supplierId)
->getOneOrNullResult();
这篇关于在多个嵌入式集合表单中查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!