如何在Symfony中为每个实体创建删除按钮?

I am creating a simple post system with the Symfony 2 framework. I want the page to display a list of DiscussionPost entities that are fetched from the database. For each post, I want to render a small delete button that will remove the respective post and persist the deletion to the database if the User field matches the currently logged in user.

Here is the entity file for DiscussionPost.

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="discussion_post")
*/
class DiscussionPost
{
    /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    /**
    * @ORM\ManyToOne(targetEntity="User")
    */
    protected $user;

    /**
    * @ORM\Column(type="string", length=140, nullable=false)
    */
    protected $text;

    /**
    * @ORM\Column(type="datetime", nullable=false)
    */
    protected $postTime;

// getters and setters...

I have already looked at the form collection article in the Symfony Cookbook:

How to Embed a Collection of Forms

However, this example is for multiple Tasks, each with a list of Tags that can be modified. My case is more similar to a list of Tasks that needs to be modified.

I also plan to have a form below the list of posts that is used to add a new post and persist it to the database.

Add a delete form for each record in your template with just the button and id in a hidden field and use jQuery to remove the item from the page and to AJAX so you don't have to reload the page every time.