sonata admin添加richhtml编辑器来阻止内容

时间:2014-10-24 14:54:12

标签: symfony sonata-admin symfony-sonata sonata

我想将ckeditor添加到阻止管理员的内容字段中。 这就是我到现在所做的事情:

  1. 将raw_content和content_formatter属性添加到我的块
  2. 将TextBlockService中的buildEditForm修改为:

    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
    {
    $formMapper->add('settings', 'sonata_type_immutable_array', array(
        'keys' => array(
            array('content', 'sonata_formatter_type', array(
                'event_dispatcher' => $formMapper->getformBuilder()->getEventDispatcher(),
                'format_field'   => ['content_formatter'],
                'source_field'   => ['raw_content'],
                'source_field_options'      => array(
                    'attr' => array('class' => 'span10', 'rows' => 10)
                ),
                'listener'       => true,
                'target_field'   => ['content']
            )),
        )
    ));
    }
    
  3. 它工作得很好,允许我从编辑器列表中选择'richhtml'但是当我尝试保存块时会抛出错误:

    Expected argument of type "string or Symfony\Component\PropertyAccess\PropertyPathInterface", "NULL" given 
    

    我该如何解决?

1 个答案:

答案 0 :(得分:3)

这是应该如何工作:

$formMapper->add('settings', 'ckeditor', array());