Symfony 2.2 and entity of choice field

New topics about Symfony 2 should go here

Moderators: tiagojsag, dcobalt

Symfony 2.2 and entity of choice field

Postby ilGrafico » Thu May 09, 2013 6:09 am

Hi, I'm new of forum,
I have a trouble on retrieve the entity of a children of main form (a doctrine choice field)

In my entity "House" I have:

/**
* @var \Door
*
* @ORM\ManyToMany(targetEntity="Door")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Door", referencedColumnName="id")
* })
*/
private $door;

/**
* @var \Window
*
* @ORM\ManyToMany(targetEntity="Window")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="window", referencedColumnName="id")
* })
*/
private $window;

In my form "house" I have:

->add('window', null, array('required' => false, 'expanded' => true, 'multiple' => true))
->add('door', 'entity', array(
'class' => 'Acme\ApplicationBundle\Entity\Door',
'expanded' => true,
'multiple' => true
))

In my Twig template I have:

{% for idx,child in form.door %}
<tr id="DataRow{{ idx }}" class="door">
<td> {{ form_widget(child, {'attr': {'class': 'checkbox', 'style': 'opacity: 0;'}}) }}</td>
<td> <!-- HERE NEED A NAME OF DOOR (getName) --></td>
</tr>
{% endfor %}

In the second td I need to insert the name of the entity door...
I search on google but I find only this method:

{{ child.vars.value.nome }} (error because value is 1, not the entity)
{{ child.vars.value.getNome() }} (error because value is 1, not the entity)
{{ child.vars.data }} (error because data is null)

Can Help me ?

tx
ilGrafico
Junior Member
 
Posts: 1
Joined: Thu May 09, 2013 5:55 am

Return to General Symfony 2 discussion

Who is online

Users browsing this forum: Bing [Bot] and 7 guests