mardi 21 avril 2015

Symfony2 get all selected checkbox

I'm working in a Symfony2 project, and i have an entity called File. In a page i have a list of files and i added a check-box for each file, and what i want is to have a submit button at the end of the files list and when i click the button i want the files to be deleted. I've already implement the action that will delete the files but i don't know how to get the selected files so i can pass them to the deleteAction($files).

here is the code of the twig file:

<tr>
<th>File name</th>                      
<th>Commentary</th>
<th>Size</th>
<th>Product/ SN</th>
<th>Added at(UTC)</th>
</tr>

{% for file in allFiles %}
   <tr>                         
     <td class="name">
       <form name="form1" method="post" action="">
         <input type="checkbox" name="check_file"> {{ file.filename }}
       </form>                              
     </td>                                     

   <td>{{ file.uploaderComment }}</td>
   <td>{{ _self.bytesToSize(file.filesize) }}</td>


   <td>{{ file.product }}</td>
   <td>{{ file.added |date("Y/m/d H:i:s","UTC") }}</td>

  </tr>
 {% endfor %}

Aucun commentaire:

Enregistrer un commentaire