如何通过Doctrine 2保存到DB CKeditor值

时间:2017-04-09 16:07:28

标签: php doctrine-orm ckeditor nette

我与Nette,Doctrine 2合作。 当我想通过Doctrine 2从表单中保存CKeditor值时,它会裁剪相同的HTML标签并且它不会保存好。 我的方法保存文章。

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();
}

变量$ data->内容具有值:

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

但它保存到数据库:

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

你知道吗,它的错误在哪里?如何使用Doctrine 2保存CKeditor值

1 个答案:

答案 0 :(得分:1)

也许你应该使用文本而不是字符串,而不是长度值。

  

Doctrine 2文本字段类型:

     

映射并转换没有最大长度的字符串数据。如果你不这样做   知道要存储的数据的最大长度,你应该考虑   使用这种类型。始终从数据库中检索的值   转换为PHP的字符串类型,如果没有数据则为null。