title: Symfony 3 using the delete action in Twig
body: <p>So I've copied the basic delete action from the <a href="https://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_doctrine_crud.html" rel="noreferrer">CRUD generator</a>:</p>
  
  <pre><code>   /**
      * @Route("category/delete/{id}", name="category_delete")
      * @Method("DELETE")
      */
      public function deleteAction(Request $request, $id)
      {
          $repository = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:Category');
          $category = $repository-&gt;find($id);
  
          $form = $this-&gt;createDeleteForm($category);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;remove($category);
              $em-&gt;flush();
          }
  
          return $this-&gt;redirectToRoute('category_index');
      }
  
      /**
       *
       * @param Category $category
       *
       * @return \Symfony\Component\Form\Form The form
       */
      private function createDeleteForm(Category $category)
      {
          return $this-&gt;createFormBuilder()
              -&gt;setAction($this-&gt;generateUrl('category_delete', array('id' =&gt; $category-&gt;getId())))
              -&gt;setMethod('DELETE')
              -&gt;getForm()
              ;
      } 
  </code></pre>
  
  <p>However, I'm not sure how to actually use the action itself. I want to do deletes in two places, and I'm not sure the correct way to do either:</p>
  
  <ol>
  <li>Deletes in the edit action - How do I add a delete button to the form builder? I do I have to do it in the twig template itself?</li>
  <li>Deletes in the index - I know how to call actions (e.g. <code>&lt;a href="{{ path('category_edit', {'id': cat.id}) }}" class="btn btn-default"&gt;Edit&lt;/a&gt;</code>), but this doesn't work with the delete action. </li>
  </ol>
  
  <p>I've tried looking at the <a href="https://github.com/symfony/symfony-demo/tree/master/app/Resources/views/admin/blog" rel="noreferrer">Symfony demo application</a>, but I still don't fully grasp how the delete action is meant to work - and I can't find anything in the docs. </p>
  
  <p>Can someone provide a brief of explanation of how the delete action works in regard to 1 and 2? </p>