【问题标题】:Not all html tags get stored with ckeditor in laravel并非所有 html 标签都在 laravel 中使用 ckeditor 存储
【发布时间】: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

标签: php laravel ckeditor


【解决方案1】:

将此行放在您的 customConfig.js 中

config.allowedContent = true;

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

【讨论】:

    猜你喜欢
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-09
    • 2014-03-29
    • 2019-01-18
    • 2011-06-23
    相关资源
    最近更新 更多