Q:

Edit Entity with multiple Addresses in the same Symfony2 twig

I have an Entity which represents an Instituion. As so, This Institution has multiple addresses (Adress Entity) each one with Street, Postal code, etc.
The thing is: I have a twig which shows everything about the institution, including a table of addresses where the institution is placed.
All i wanted was to click in one address in the table and have a popup window to edit the address (And then Save button would pass the id of the address to a controller function).
What is the best way to do this? The problem here is that i do not have the id of the address until someone clicks on hit. And then i have to fill the form with the correct information.
Here is what i have:
The table of adresses (in the twig):
<tbody>
    {% for local in locais %}
        <tr class="odd gradeX"> 
            <td>{{ local.name}}</td>
        <td>{{ local.address}}</td>
            <td>{{ local.postalCode}}</td>
            <td><a title="Editar" class="label label-info" 
                         onclick="editLocal('{{ local.name}}',  
                                     '{{ local.address}}',
                                     '{{ local.postalCode }}'
                                     '{{ local.id }}');">
                         <i class="icon-edit icon-white"></i></a></td>
        </tr>
    {% endfor %}
</tbody>

Then I have the following javascript function that fills the edit local form:
function editLocal(name, address, postalCode, id){

oFormObject = document.forms['editLocal']; 
oFormObject.elements['fccn_corebundle_localtype_id'].value = id;
oFormObject.elements['fccn_corebundle_localtype_name'].value = name;
oFormObject.elements['fccn_corebundle_localtype_address'].value = address;
oFormObject.elements['fccn_corebundle_localtype_postalCode'].value = codigoPostal;

$('#editLocal').modal('show');
};

Everything works ok here!
The form pops up with the correct information!
Then all i wanted was to get the id and pass it to the controller with the edited information so i can persist the existent local entity!
I have the following!
<form id="editLocal" class="form-horizontal" 
    action= "{{ path('FccnEduroamEntidadeBundle_editLocal', 
                 { 'idLocal': editLocalForm.vars.value.id }) }}" 
    method="post" {{ form_enctype(editLocalForm) }}>

        {{ form_row(editLocalForm.name) }}
        {{ form_row(editLocalForm.address) }}
        {{ form_row(editLocalForm.postalCode) }}
            {{ form_rest(editLocalForm) }}

        <div class="form-actions">
            <button class="btn" type="submit">Guardar</button>
        </div>
</form> 

The problem here is that editLocalForm.vars.value.id returns absolutly nothing!
But when i check this tag on chrome i have:
<input type="hidden" id="fccn_corebundle_localtype_id" name="fccn_corebundle_localtype[id]" value="1"> 
Is there a better way to do this? Any help would be really appreciated.
Thanks.
Afonso

A:

I am not sure if i get you right, but i would say:
Why do you want the id in the route for your controller?  
You could get the id via POST and pass it to persist.
As far as i understand the id is set in the form via javascript to the input field    
<input type="hidden" id="fccn_corebundle_localtype_id" name="fccn_corebundle_localtype[id]" value="1">

So it should be there in your request and you actually dont need it in the route.

