【发布时间】:2015-10-07 01:36:46
【问题描述】:
我有两个实体:多对多关系中的 BlogPost 和关键字。我必须使用表单同时在数据库中添加 BlogPost 和关键字。我想使用像Bootstrap tagsinput 这样的jquery 标签输入插件在输入中插入关键字。请问我该如何实施?有我的实体:
class BlogPost
{
//...
/**
* @var \Doctrine\Common\Collections\ArrayCollection
* @ORM\ManyToMany(targetEntity="ESGISGabon\PostBundle\Entity\Keyword", cascade={"persist"})
*/
private $keywords;
public function __construct()
{
$this->keywords = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getKeywords()
{
return $this->keywords;
}
}
class Keyword
{
/**
* @var string
* @ORM\Column(type="string", name="category_title", nullable=false, length=30)
*/
protected $title;
public function getTitle()
{
return $this->title;
}
}
【问题讨论】:
-
实体(模型)和设计(视图)之间没有联系...