symfony entity type query builder access in class

309 Views Asked by At
$builder
->add(
                'category',
                'entity',
                array(
                    'class' => 'path/to/my/entity/class',
                    'query_builder' => function (EntityRepository $em){
                            return $em->createQueryBuilder("s");
                        },
                    'expanded' => TRUE,
                    )
                )

this is from my form type.. Is there a way for me to us the returned object in query_builder parameter in twig..

{% for category in category %}}
    {{form_widget(category)}}
    // here i want to access the category other property.. 
    // can we do it like 
    //{{category.getId()}}

{% endfor %}

my goal is to create a radio button for an entity but it renders extra information with it ..

An Example:

Category
  [radio button] <sub category label>
     <sub category>
1

There are 1 best solutions below

0
On

I Figured how answer my own question..

What I did is to create twig extension that accepts that accepts the id of category then fetch the whole object and then i can use it already