symfony2表单选择和mongodb

val*_*lis 9 mongodb symfony-forms symfony

使用Entity时,我们可以通过表单字段类型实体从Entity加载选项

$builder->add('group', 'entity', array(
    'class' => 'Fist\CoreBundle\Document\Group',
));  
Run Code Online (Sandbox Code Playgroud)

但是当使用mongodb文档时,从Document中注入选择选项的最佳方法是什么?

在我的情况下从组文档加载所有组.有没有比传递给构造函数更好的方法呢?

谢谢你们

dyl*_*ver 6

该学说的MongoDB ODM相当于EntityTypeSymfony\Bundle\DoctrineMongoDBBundle\Form\Type\DocumentType.DocumentChoiceList,DocumentsToArrayTransformerDocumentToIdTransformer,也包含在DoctrineMongoDBBundle中并且与它们的ORM等价物并行.


Per*_*ana 6

更改entitydocument,您只需使用快捷方式即可.例如:FistCoreBundle:Group