Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 form choice and 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',
));  

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?

Thank you all

like image 425
valdas.mistolis Avatar asked Oct 10 '11 06:10

valdas.mistolis


1 Answers

I had to partially stray from Dylan Oliver's answer.

Symfony\Bundle\DoctrineMongoDBBundle\Form\Type\DocumentType

could not be found, as of November 2016 DocumentType seems to reside here:

Doctrine\Bundle\MongoDBBundle\Form\Type\DocumentType
like image 109
Francesco Mastellone Avatar answered Oct 20 '22 16:10

Francesco Mastellone