我在使用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'
))
...
我在我的 textarea 中看到一个 textarea 但没有 ckeditor,我错过了什么?这是我在浏览器中看到的:
我也没有收到任何控制台错误或其他错误......