【问题标题】:sonata admin add richhtml editor to block content奏鸣曲管理员添加richhtml编辑器以阻止内容
【发布时间】:2014-12-20 10:39:43
【问题描述】:

我想将 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 

我该如何解决这个问题?

【问题讨论】:

    标签: symfony sonata-admin symfony-sonata sonata


    【解决方案1】:

    它应该是这样工作的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-11
      • 2019-02-12
      • 2018-04-30
      • 2019-01-14
      • 1970-01-01
      • 2018-03-22
      相关资源
      最近更新 更多