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