title: How to get the value of multiple checkbox elements with the same name in my controller
body: <p>I have following code in my twig file:</p>
  
  <pre><code>&lt;form method ="POST" action="{{path('deleteMessages')}}"&gt;
                  {% for message in pmReceived %}
                      {% if message.isread == false  %}
                          {% if message.showincoming == true  %}
                              &lt;div class="border"&gt;
                                  &lt;div  class="pmbox"&gt;
                                      &lt;p class="pmsender"&gt;{{message.sender}}&lt;/p&gt;&lt;p class="pmdate"&gt;{{message.date|date('d-m-Y H:i:s') }}&lt;/p&gt;&lt;p class="pmsubject"&gt;{{message.subject}}&lt;/p&gt;&lt;input type="checkbox" name="deletePm" value="{{message.pmid}}"&gt;
                                  &lt;/div&gt;
                                  &lt;div class="pmcontents"&gt;
                                      &lt;p class="titleContent"&gt;Contents:&lt;/p&gt;
                                      &lt;p&gt;{{message.contents}}&lt;/p&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          {% endif %}
                      {% endif %}
                  {% endfor %}
                  {% for message in pmReceived %}
                      {% if message.isread == true %}
                          {% if message.showincoming == true  %}
                              &lt;div class="border"&gt;
                                  &lt;div class="pmbox"&gt;
                                      &lt;p class="pmsender"&gt;{{message.sender}}&lt;/p&gt;&lt;p class="pmdate"&gt;{{message.date|date('d-m-Y H:i:s') }}&lt;/p&gt;&lt;p class="pmsubject"&gt;{{message.subject}}&lt;/p&gt;&lt;input type="checkbox" name="deletePm" value="{{message.pmid}}"&gt;
                                  &lt;/div&gt;
                                  &lt;div class="pmcontents"&gt;
                                      &lt;p class="titleContent"&gt;Contents:&lt;/p&gt;
                                      &lt;p&gt;{{message.contents}}&lt;/p&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          {% endif %}
                      {% endif %}
                  {% endfor %}
                  &lt;button class="deleteButton" type="submit"&gt;Delete selected messages&lt;/button&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>This is my controller code:</p>
  
  <pre><code>public function deleteMessagesAction(Request $request) {
      if (false === $this-&gt;get('security.context')-&gt;isGranted('IS_AUTHENTICATED_FULLY')) {
          throw $this-&gt;createAccessDeniedException('Unable to access this page!');
      }
  
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
      $pm = $this-&gt;getDoctrine()
              -&gt;getRepository('LoginLoginBundle:Privatemessage')
              -&gt;findBypmid($request-&gt;get('sentValue'));
      $deleteMessages = $request-&gt;get('deletePm');
      var_dump($deleteMessages);
  
      $user = $this-&gt;get('security.context')-&gt;getToken()-&gt;getUser();
      $pmReceived = $this-&gt;getDoctrine()
              -&gt;getRepository('LoginLoginBundle:Privatemessage')
              -&gt;findByReceiver($user-&gt;getUsername());
  
      $pmSent = $this-&gt;getDoctrine()
              -&gt;getRepository('LoginLoginBundle:Privatemessage')
              -&gt;findBySender($user-&gt;getUsername());
  
      return $this-&gt;render('LoginLoginBundle:Default:pmPage.html.twig', array('pmReceived' =&gt; $pmReceived, 'pmSent' =&gt; $pmSent, 'toDelete'=&gt;$deleteMessages));
  
  }
  </code></pre>
  
  <p>Now I want to get the value of all the 'ticked' checkboxes, I supposed $deleteMessages would be an array of values, but it only holds the last checkbox that is ticked.</p>
  
  <p>How can I get an array of all the values in my controller?</p>