如何添加CKEditor到Sonata管理后台的文本区 [英] How to add CKEditor to Sonata Admin backend's textareas

查看:143
本文介绍了如何添加CKEditor到Sonata管理后台的文本区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将CKEditor添加到Sonata Admin后端。现在我只有Create Bundle运行,这允许我在内联编辑内容,但我想在后端使用编辑器。我尝试了Formatter Widget,但是它有点大,因为我不想在我的实体中创建新字段。

I'd like to add CKEditor to the Sonata Admin backend. For now I only have Create Bundle running, which allows me to edit the content inline, but I'd like to use an editor in the backend too. I tried Formatter Widget, but it is a little oversized, since I do not want to create new fields in my entities.

有人已经做了这个吗?

推荐答案

zizoujab的解决方案是完全正确的,所以我upvote它。但是,由于我的问题涉及到SonataAdminBundle,需要做一些更多。这是为什么我给这个额外的答案。

The solution of zizoujab was totally correct, so I upvoted it. But, as my question refered to SonataAdminBundle, there need to be done a little more. That's why I give this additional answer.

我通过覆盖 SonataAdminBundle:CRUD:edit.html.twig 在自定义捆绑中:

I solved this by overriding the SonataAdminBundle:CRUD:edit.html.twig in a custom bundle:

{% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %}

{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/ckeditor/adapter/jquery.js') }}" type="text/javascript"></script>
    <script src="{{ asset('js/ckeditor/ckeditor.js') }}" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            $('textarea.ckeditor').ckeditor();
        });
    </script>
{% endblock %}

也有我的问题,因为我使用的ckeditor的版本。我无法使用一个,CmfCreateBundle安装。这产生了一些js错误,并且< textarea> 标记消失了。
所以我不得不从ckeditor.com下载标准版本,它工作。

Also I had the problem, that this didn't work because of the version of ckeditor I used. I was not able to use the one, CmfCreateBundle installs. This generated some js errors and the <textarea> tag vanished. So I had to download the "standard" version from ckeditor.com, which worked.

这篇关于如何添加CKEditor到Sonata管理后台的文本区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆