I want to update a row of my tables .
When the user click on the icone of modify i want to redirect him in form that already get the information of row selected.
in the controller :
public function modifyBuAction($id){
$entite=$this->get('entite.entiteservice')->findEntiteById($id);
$form = $this->get('form.factory')->create(new BuType(), $entite); // On bind l'objet Entite à notre formulaire BuType
if ('POST' == $request->getMethod()) { // Si on a posté le formulaire
$form->bind($request);
if ($form->isValid()) { // Si le formulaire est valide
$this->get('entite.entiteservice')->saveEntite($entite); // On utilise notre Manager pour gérer la sauvegarde de l'objet Conge
return $this->render('acmeBundle:admin:index.html.twig');
}
}
return $this->render("acmeBundle:admin:modifyBu.html.twig",array("entite"=>$entite));
}
in the twig :
<form action="{{ path('modify_bu') }}" method="post" id="bu_form" >
</br>
<table class="form">
<tr>
<td class="col1">
<label>
{{ form_errors(form.nomEntite) }}
{{ form_label(form.nomEntite, 'Nom entite:') }}
</label>
</td>
<td class="col2">
{{ form_widget(form.nomEntite) }}
</td>
</tr>
<tr>
<td class="col1">
<label>
{{ form_errors(form.nomAgence) }}
{{ form_label(form.nomAgence, 'Nom agence:') }}
</label>
</td>
<td class="col2">
{{ form_widget(form.nomAgence) }}
</td>
</tr>
<tr>
<td class="col1">
<label>
{{ form_errors(form.entiteAbrev) }}
{{ form_label(form.entiteAbrev, 'abreviation entite:') }}
</label>
</td>
<td class="col2">
{{ form_widget(form.entiteAbrev) }}
</td>
</tr>
<tr>
<td class="col1">
<label>
{{ form_errors(form.entiteNiveau) }}
{{ form_label(form.entiteNiveau, 'Niveau abreviation:') }}
</label>
</td>
<td class="col2">
{{ form_widget(form.entiteNiveau) }}
</td>
</tr>
</table>
in the BuType :
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nomEntite')
->add('nomAgence')
->add('entiteAbrev')
->add('entiteNiveau');
}
i get this in the twig of table:
<table class="data display datatable" id="example">
<thead>
<tr>
<th>Nom Entite</th>
<th>Nom Agence</th>
<th>Abréviation Entite</th>
<th>Niveau Entite</th>
<th>Modifier/Supprimer</th>
</tr>
</thead>
<tbody>
{% for entite in liste %}
<tr class="odd gradeX">
<td> {{ entite.nom_entite }} </td>
<td> {{ entite.nom_agence }} </td>
<td> {{ entite.entite_abrev }} </td>
<td> {{ entite.entite_niveau }} </td>
<td>
<a href={{ path('modify_bu', {'id': entite.id}) }}><img src="{{ asset('bundles/acme/img/modifier.png')}}" width="20" height="20" /></a>
<a href={{ path('delete_bu', {'id': entite.id}) }} onclick="myFunction()"><img src="{{ asset('bundles/acme/img/delete.png')}}" width="20" height="20" /></a>
</td>
</tr>
{% endfor %}
when i clik on the icone of modification i want to get a form with the information of row selected
any help please?