并非所有 html 标签都在 laravel 中使用 ckeditor 存储

Posted

技术标签:

【中文标题】并非所有 html 标签都在 laravel 中使用 ckeditor 存储【英文标题】:Not all html tags get stored with ckeditor in laravel 【发布时间】:2016-02-02 15:51:50 【问题描述】:

我在我的 laravel 项目中使用 ckeditor。我的问题不是所有的 html 标签都插入到我的数据库中。

这是我在 ckeditor 中的源 html 示例: <h1><font face="courier new, courier, monospace"><strong>this value of textarea</strong></font></h1>

当我点击提交时,只有<strong>this value of textarea</strong> 插入到我的数据库中。

我 print_r(Input::all()); 时的输出:

Array
(
    [_token] => xVqWzYv0WK9w7xLJjcDHW6kCQARCChaGzVM9usbU
    [title] => test title
    [summary] => <h1><font face="courier new, courier, monospace"><strong>this value of textarea</strong></font></h1>
    [category] => 20
)

这是我的代码:

$post = $this->question->getById($id);
if ( ! $this->validator->validEdit(Input::all()))

  return Redirect::back()->withInput()->withErrors($this->validator->errors());

$post = $this->question->edit($post, Input::all());

【问题讨论】:

你能分享你的编辑方法的代码吗?我想,它是将返回的数据添加到数据库中的那个。确保使用 PDO 或尝试 php $post->summary = mysql_real_escape_string($post->summary) 。 鳕鱼看起来一切都很好,也许你搞砸了别的东西? 在数据库中检查您的Length/Values 【参考方案1】:

将此行放在您的 customConfig.js 中

config.allowedContent = true;

您可以阅读更多关于允许的内容规则here

【讨论】:

以上是关于并非所有 html 标签都在 laravel 中使用 ckeditor 存储的主要内容,如果未能解决你的问题,请参考以下文章

数组4:数组中使奇数都在偶数前面的三道题

BayesSearchCV 跳过:ValueError:并非所有点都在空间范围内

MySQL 和 Python:并非所有参数都在 SQL 语句中使用

Azure 存储表 - 并非 TableEntity 中的所有属性都在 InsertOperation 之后存储

并非所有 graphql 查询数据都在 GatsbyJS 页面上呈现

typeError:并非所有参数都在字符串格式化期间进行了转换