This is my PHP code where i am trying to get the "ApartmentId" when the button "myOnbutton" is being clicked.
if (isset($_POST['myOnbutton'])) {
$providerstatss = $this->getDoctrine()
->getRepository('myBundle:UserStats')
->findByApartmentId($_POST);
}
This is my code for my button in twig ---
<form method="post" action="#">
<div class="container">
<h3>Content Management</h3>
<table class="table table-content">
<tbody>
{% for userStats in userStats %}
<td>
<button type="submit" class="btn btn-default btn-xs myOnbutton">ON</button>
</td> </tbody>
</table></form>
It is not working for me, i am also not sure about this method ->findByApartmentId($_POST); , the column name is "ApartmentId".
So I need to actually get the "UserStats.ApartmentId" when the button clicked.
How can I get the "ApartmentId" when the button is clicked?
Does anyone know how to solve this problem? Thanks in advance
$_POST
is an array, so you have to use a key to extract a value (like$_POST['ApartmentId']
) 2) The form is missing any field apart from the button, so where is yourApartmentId
value inside that form? – Matteo G. Aug 5 '15 at 14:25{% for userStats in userStats %}
without an{% endfor %}
2) Your form is still missing a value forApartmentId
(the button alone is useless) – Matteo G. Aug 5 '15 at 14:39