symfony2形式选择和mongodb [英] symfony2 form choice and mongodb

查看:58
本文介绍了symfony2形式选择和mongodb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用实体时,我们可以通过表单域类型实体从实体中加载选择

When using Entity we can load choices from Entity via form field type entity

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

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

but when using mongodb document what is the best way to inject select options from Document?

从组"文档中加载所有组".有没有比传递给表单构造函数更好的方法了?

in my case load all Groups from Group document. Is there better way to do that than passing to form constructor?

谢谢大家

推荐答案

entity更改为document,您可以使用快捷方式.例如:FistCoreBundle:Group

Change entity to document, and you can just use the shortcut. ex: FistCoreBundle:Group

这篇关于symfony2形式选择和mongodb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆