I want to get the value of an input field from my template twig with twig not with javascript. My input field hasn't a form, it is a hidden input.
{% block body -%}
<input type="hidden" name="id_client" id="id_client" value="123"/>
...
{% endblock %}
I want to do this:
{{ path('client_view',{"id": value_Of_Hidden_Input}) }}
How can I get value_Of_Hidden_Input
EDIT:
My requirement:
I have a list of customers and I have for each customer a button to show details of customer "Modifier coordonnées".
I want on clicked one customer a function AJAX will executing the action showAction
This is my code:
{% block body -%}
<div class="tab-client">
<table id="mytable" class="table table-bordred table-striped" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>Raison Sociale</th>
<th>Identifiant</th>
<th>M. de passe</th>
<th>Solde actuel</th>
<th class="text-center sty-td-action">Action</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td>{{ entity.raisonSociale}} </td>
<td>{{ entity.login }}</td>
<td>{{ entity.password }}</td>
<td>{{ entity.soldeSMS }}</td>
<td>
<a class="modifier-client" id="modif_coordonnee"><span class="glyphicon glyphicon1">Modifier coordonnées</span></a>
<a href="#historique" class="modifier-client"><span class="glyphicon glyphicon2">Voir Historique</span></a>
<a href="#ajout" class="modifier-client"><span class="glyphicon glyphicon3">Ajout transaction</span></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div><!--tab-client-->
{% endblock %}
{% block javascripts %}
<script>
$("#modif_coordonnee").click(function() {
$.ajax({
//On lui indique le type d'envoie des informations
type: 'POST',
//On lui indique le chemin de la fonction
url: '{{ path('client_show',{"id": value_of_id_client}) }}',
//On lui donne la valeur du choix qu'on a fait, et id est la variable qui va contenir notre valeur, nous la retrouvons dans notre controller
//Enfin nous lui disons de remplir notre formulaire avec le resultat
success: function(response)
{
......
}
}
)});
</script>
{% endblock %}
My problem is how can determined value_of_id_client?
input-field and especially itsvalueconning from? Is it a form row, like{{ form_row(form.id_client) }}?