symfony3& SonataAdmin& Formatter Bundle - 使用格式化程序选项时出错" target_field"不存在

时间:2016-09-14 07:34:12

标签: symfony sonata-admin

我正在使用symfony 3.1.4 并安装SonataAdminBundle,SonataFormatterBundle。 我在使用Sonata Formatter Bundle时遇到了麻烦。

  1. 按此guide安装SonataFormatterBundle:

  2. 我有一个实体:BlogSpost有3个字段:

  3. /**
     * @var string
     *
     * @ORM\Column(name="body", type="blob")
     */
    private $body;
    /**
     * @var string
     *
     */
    private $rawBody;
    /**
     * @var string
     *
     */
    private $bodyFormatter ;
    
    1. 这是我在BlogPostAdmin类中的formmapper
    2. class BlogPostAdmin extends AbstractAdmin
      {
          protected function configureFormFields(FormMapper $formMapper)
          {
              $formMapper->add('title', 'text')
                  ->add('bodyFormatter', 'sonata_formatter_type', array(
                      'source_field'         => 'rawBody',
                      'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)),
                      'format_field'         => 'bodyFormatter',
                      'target_field'         => 'body',
                      'event_dispatcher'     => $formMapper->getFormBuilder()->getEventDispatcher()
                  ))
                  ->add('draft')
                  ->add('published_time');
          }
          // ...
      
      1. 但是我在尝试创建帖子时会收到以下错误。
      2.   

        选项" event_dispatcher"," format_field"," source_field"," source_field_options"," target_field"不存在。定义的选项包括:"操作"," allow_extra_fields"," attr"," auto_initialize"," block_name",& #34; by_reference","复合","约束"," csrf_field_name"," csrf_message"," csrf_protection&# 34;," csrf_token_id"," csrf_token_manager","数据"," data_class","禁用",&# 34; empty_data"," error_bubbling"," error_mapping"," extra_fields_message"," horizo​​ntal_input_wrapper_class"," horizo​​ntal_label_class&#34 ;," horizo​​ntal_label_offset_class"," inherit_data"," invalid_message"," invalid_message_parameters"," label",&#34 ; label_attr"," label_format"," label_render","映射","方法"," post_max_size_message" ," property_path"," required"," sonata_admin"," sonata_field_description"," sonata_help"," translat ion_domain"," trim"," validation_groups"。   500内部服务器错误 - UndefinedOptionsException

        如何解决此问题?

1 个答案:

答案 0 :(得分:0)

symfony 3.1.4,option resolver is one of them存在许多兼容性问题。 我建议尝试使用#x; formatter-bundle 4.x-dev',其中包含其他问题。

此外:

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

已弃用且

    form_themes:    
        - 'SonataFormatterBundle:Form:formatter.html.twig'
应该使用