title: Symfony2 Delete record from table
body: <p>I have a button in my twig that I want to be able to delete a record from a table with.When I hit the delete button the page reloads but no record is deleted.</p>
  
  <p>here is my twig</p>
  
  <p></p>
  
  <pre><code>&lt;h1&gt;Admin Area - The football blog&lt;/h1&gt;
   &lt;table class="zebra"&gt;
   &lt;thead&gt; 
       &lt;tr&gt;
        &lt;th&gt;Title&lt;/th&gt;
          &lt;th&gt;Date&lt;/th&gt;       
          &lt;th&gt;Action&lt;/th&gt;
       &lt;/tr&gt;
     &lt;/thead&gt; 
     &lt;tbody&gt; 
       &lt;tr&gt;
       {% for entity in adminentities %}
          &lt;td&gt;{{entity.postTitle}}&lt;/td&gt;
          &lt;td&gt;{{ entity.postDescription }} &lt;/td&gt;      
          &lt;td&gt; &lt;a href="{{ path('deletepost', { 'id': entity.id })     }}"&gt;Delete&lt;/a&gt; || Edit&lt;/td&gt;
        &lt;/tr&gt;
  
       {% endfor %}
  
       &lt;/tbody&gt; 
   &lt;/table&gt;
  </code></pre>
  
  <p>Here is my controller. </p>
  
  <pre><code>  /**
   * @Route("/posted/admin", name="deletepost")
   * @Template()
   */
  
  public function admindeleteAction($id)
  {
  
     $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
     $adminentities = $em-&gt;getRepository('BlogBundle:posted')
                         -&gt;findOneBy(array('post'=&gt;$post-&gt;getId(),     'id'=&gt;$id));
  
     $em-&gt;remove($adminentities);
      $em-&gt;persist($adminentities);
         $em-&gt;flush();                                                     
     return $this-&gt;render('BlogBundle:Default:admin.html.twig');
  }
  </code></pre>