繁体   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