0

我想将 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']
            )),
        )
    ));
    }
    

它工作得很好,允许我从编辑器列表中选择“richhtml”但是当我尝试保存块时它会抛出一个错误:

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

我该如何解决?

4

1 回答 1

3

以下是它的工作方式:

$formMapper->add('settings', 'ckeditor', array());
于 2014-10-26T14:33:16.863 回答