2017-04-09 47 views
0

我有Nette和Doctrine 2的項目。 當我想從Doctrine 2的表單中保存CKeditor的值時,它會裁剪相同的HTML標籤,並且不會保存好。 我的方法保存文章。如何通過Doctrine 2保存到DB CKeditor的值

public function addArticle($creator, $data) { 
    $article = new Article(); 
    $article->setCategory($data->category); 
    $article->setContent($data->content); 
    $article->setTitle($data->title);  
    $this->em->persist($article); 
    $this->em->flush(); 
} 

變量$數據 - >內容具有價值:

<h1>My first article</h1> 
<p><strong>One bold line</strong></p> 
. 
. 

但它保存到數據庫:

<h1>My first article</h1> 
<p> 

你知道,它的錯誤?如何使用Doctrine 2保存CKeditor的值

+0

對不起。 :((我有db的列爲varchar(45)。我感覺不好。 – ondrusu

回答

1

也許你應該使用文本而不是字符串,沒有長度值。

學說2文本字段類型:

地圖和字符串數據轉換而不的最大長度。如果您不知道要存儲的數據的最大長度,您應該考慮使用此類型的 。從數據庫檢索到的值始終是 轉換爲PHP的字符串類型,如果沒有數據存在,則返回null。

+0

是的,我使用了。我有db模型'內容文本'芽,我不知道,爲什麼我用'varchar (name =「some_field」);我沒有看到我是如何創建表格的。謝謝您的推薦。我如何在實體中定義列? – ondrusu

+1

/** * @var字符串 * * @ORM \ Column(name =「some_field」 ,type =「text」) */ private $ someField; 這被映射爲mySQL中的longtext字段。 –