簡體   English   中英

setVariables()多對多關系symfony2

[英]setVariables() many to many relation symfony2

我說實體A和實體B之間有很多對很多的關系,我將使用嵌入的形式,以便按如下所示的實體B形式添加實體A的屬性

$builder ->add('entityAs', 'entity', array(
              'class'    => 'xxxBundle:EntityA',
              'property' => 'name',
              'multiple' => false,
            ));}

當我將“ multiple”設置為true時,一切正常。 但是當我將其設置為false時,出現以下錯誤

Property "entityAs" is not public in class "xxx\Entity\EntityB". Maybe you should create the method "setEntityAs()"?

像往常一樣,您的EntityB類中的propertyEntityAs不是公開的(受保護的或私有的)。 因此,您必須為其編寫(或生成)setter:setEntityAs($ entityAs)

多個true可能有效,因為我認為(不確定)它使用addXxx Setter。 證明我,如果您的EntityB類中有addEntityAs方法?

Buuuuut,如果您具有多對多關系,為什么要將倍數設置為false?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM