Hi Carlos,

Thank you for the answer !
This is a good idea to use options to pass the EM, I will follow your
advice !
Nevertheless, it would be easier to be able to access the EM globaly,
with an utility class or whatever (and this is not restricted to the
em, but it would be great to be able to access the container from
anywhere and not only the view).

I will wait to see if my two first bugs are fixed in the (hopefully
upcoming) RC1 ! :)

Thanks again,


On 21 fév, 12:32, Carlos Sánchez <carloss...@gmail.com> wrote:
> I've got no answer to your first question, it worked fine a couple of
> commits ago... it's continuosly changing.
>
> For the second point I pass the parameter in when creating the form in
> the controller
>
> $form = MyForm::create($this->get('form.context'), 'my_namet',
>                                 array('em' => 
> $this->get('doctrine.orm.entity_manager')));
>
> and addOption/getOption  in the form class
>
> class MyForm extends Form
> {
>         public function configure()
>         {
>                 $this->addOption('em'); <<-- might go in the constructor (not
> proved)
>
>                 $em = $this->getOption('em');
>                 //...
>         }
>
> }
>
> Hope it helps!!
>
> On Feb 20, 10:16 pm, Lideln <lid...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm using the EntityChoiceField, and I encountered two issues :
> > 1) when modifying the querybuilder, the value in the html option tag
> > is not the one corresponding to the label of the option tag
> > 2) I only get one single option tag in my select, whereas I have
> > multiple rows in my db table, even when specifying the setMaxResults()
>
> > Here is the call :
> > $this->add(new EntityChoiceField('nationalité', array(
> >                                                                             
> >                                                     'property_path' => 
> > 'nationality',
> >                                                                             
> >                                                     'em' => self::$oEM,
> >                                                                             
> >                                                     'class' => 
> > 'Ratethestar\\MainBundle\\Entity\
> > \Nationality',
> >                                                                             
> >                                                     'property' => 'label',
> >                                                                             
> >                                                     'query_builder' => 
> > function($repository)
> >                                                                             
> >                                                     {
> >                                                                             
> >                                                             return 
> > $repository->createQueryBuilder('n')->orderBy('n.label', 
> > 'ASC')->setMaxResults(100);
>
> >                                                                             
> >                                                     }
> >                                                                             
> >                                             )));
>
> > Oh, last thing : how do you get the EM from a Form ? I had to create a
> > static field and provide it with the EM before creating my form.
>
> > Thank you all !
>
> > PS : still can't generate repositories :'(

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to