gpt4 book ai didi

php - CKEditor 未与 Sonata Formatter(Sonata Admin Bundle)一起显示

转载 作者:可可西里 更新时间:2023-11-01 00:05:10 27 4
gpt4 key购买 nike

我在使用 Sonata Formatter Bundle 时遇到问题.

在我的 config.yml 中,我有以下内容(除其他外):

imports:
- { resource: sonata.yml }

twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"

#sonata
form:
resources:
# ...
- 'SonataFormatterBundle:Form:formatter.html.twig'

在我的sonata.yml 文件中我有:

sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
# Your other blocks
sonata.formatter.block.formatter:

sonata_formatter:
formatters:
markdown:
service: sonata.formatter.text.markdown
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig #keep this commented unless you are using media bundle.


text:
service: sonata.formatter.text.text
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig


rawhtml:
service: sonata.formatter.text.raw
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig


richhtml:
service: sonata.formatter.text.raw
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig


twig:
service: sonata.formatter.text.twigengine
extensions: [] # Twig formatter cannot have extensions

ckeditor:
templates:
browser: 'SonataFormatterBundle:Ckeditor:browser.html.twig'
upload: 'SonataFormatterBundle:Ckeditor:upload.html.twig'

ivory_ck_editor:
configs:
default:
language: '%locale%'
toolbar: standard

sonata_admin:
templates:
layout: DXEenhanaBundle:Admin:standard_layout.html.twig

我已将所需的 CSS 和 JS 添加到我的 standard_layout.html.twig 文件中,并且它们已正确加载。

在我的管理文件中,我有以下内容:

$formMapper
->add('name', 'text', array('label' => 'Applicant Name'))
->add('contacts', 'sonata_formatter_type', array(
'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(),
'format_field' => 'contacts',
'source_field' => 'contacts',
'source_field_options' => array(
'attr' => array('class' => 'span10', 'rows' => 7)
),
'ckeditor_context' => 'default',
'listener' => true,
'target_field' => 'contacts',
'label' => 'Contacts'
))
...

我看到一个文本区域,但在我的文本区域中没有 ckeditor,我错过了什么?这是我在浏览器中看到的: enter image description here

我也没有收到任何控制台错误或其他错误...。

最佳答案

您需要按照 Sonata Admin Integration of SonataFormatterBundle Documentation 部分中的描述覆盖 admin layout.html.twig 模板.

创建一个新的模板文件app\Resources\SonataAdminBundle\views\layout.html.twig:

{% extends 'SonataAdminBundle::standard_layout.html.twig' %}

{% block stylesheets %}
{{ parent() }}

<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/skins/sonata/style.css') }}" type="text/css"
media="all"/>
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/markdown/style.css') }}"
type="text/css" media="all"/>
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/html/style.css') }}" type="text/css"
media="all"/>
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/textile/style.css') }}" type="text/css"
media="all"/>
{% endblock %}

{% block javascripts %}
{{ parent() }}

<script src="{{ asset('bundles/ivoryckeditor/ckeditor.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/vendor/markitup-markitup/markitup/jquery.markitup.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/markdown/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/html/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/textile/set.js') }}" type="text/javascript"></script>
{% endblock %}

并使用以下内容更新您的 config.yml:

sonata_admin:
templates:
layout: SonataAdminBundle::layout.html.twig

关于php - CKEditor 未与 Sonata Formatter(Sonata Admin Bundle)一起显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31142508/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com