SonataFormatter ivory_ck_editor工具栏无法显示

时间:2015-01-06 16:10:47

标签: symfony ckeditor sonata

我将SonataFormatter与SonataAdmin一起使用。我可以看到textarea但工具栏没有出现。

我可以使用下面的代码在运行时强制使用工具栏。我错过了什么吗?

CKEDITOR.replace( 'textbox id', {
toolbar: [
    { name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
    [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ],          // Defines toolbar group without name.
    '/',                                                                                    // Line break - next group will be placed in new line.
    { name: 'basicstyles', items: [ 'Bold', 'Italic' ] }
]
});

我的config.yml

sonata_formatter:
    formatters:
        markdown:
            service: sonata.formatter.text.markdown
            extensions:
                - sonata.formatter.twig.control_flow
                - sonata.formatter.twig.gist


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


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


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

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

我的管理员课程:

protected function configureFormFields(FormMapper $formMapper)
{
     $formMapper
        ->add('content', 'sonata_formatter_type', array(
          'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(),
          'format_field'   => 'contentFormatter',
          'source_field'   => 'rawContent',
          'source_field_options'      => array(
            'horizontal_input_wrapper_class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'col-lg-12': '',
           'attr' => array('class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'span10 col-sm-10 col-md-10': '', 'rows' => 20)
         ),
         'ckeditor_context'     => 'default',
         'target_field'   => 'content',
         'listener'       => true,
         ))
  ;
}

1 个答案:

答案 0 :(得分:0)

我忘记添加:

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