Greetings,

Ran into an issue with the EntityChoiceField.  I am rendering a SELECT
field with city names.  If I use a literal value (ie. 2) in the
query_builder param of the EntityChoiceField everything works
perfectly.  If I substitute that with a variable value I get an empty
select.  Also, I have printed out the value of the state_id from the
request and it prints the correct value.

Any help would be appreciated.

Roger

Here is the code where I create the field.

This is the code for the controller that is fetching the select field

$params['city_select'] = $this-
>forward('UserBundle:Ajax:getCitySelectByStateId', array(),
array('state_id' => 2))->getContent();

$params gets passed to the view

This is the code from my AjaxController which should return these db
driven fields on demand.


    public function getCitySelectByStateIdAction() {
        $em = $this->get('doctrine.orm.entity_manager');
        $request = $this->get('request');

        if(!$request->get('state_id'))
                return new Response('ERROR');  //NOT GETTING AN ERROR
HERE

        $state_id = (int)$request->get('state_id');

        $field = new EntityChoiceField($name, array(
                'em' => $em,
                'class' => 'ARN\EntityBundle\Entity\Cities',
                'property' => 'city_name',
                'query_builder' => function($repository) {
                     return $repository->createQueryBuilder('cities')-
>where('cities.state_id = :state_id')->setParameter('state_id',
$state_id);
                                           }
        ));

        return $this->render('UserBundle:Ajax:form_field.html.twig',
array('field' => $field));
    }

-- 
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