2015-01-06 73 views
0

我使用SonataFormatter和SonataAdmin。我可以看到textarea,但工具欄沒有出現。SonataFormatter ivory_ck_editor工具欄不顯示

我可以強制工具欄在運行時與代碼波紋管。我錯過了什麼嗎?

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, 
     )) 
    ; 
} 

回答

0

我忘了補充:

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

您好,我在這裏,這裏有同樣的問題你添加了嗎? – MauJFernandez

+1

在我的config.yml文件中 – Sancho

+0

謝謝,它實際上是在樹枝下,你應該在你的文章的「表單」之前添加它以避免混淆。 – MauJFernandez