我使用symfony 3.1.4并安装SonataAdminBundle, SonataFormatterBundle。我在使用Sonata Formatter Bundle时遇到了问题。
-
安装SonataFormatterBundle:
-
我有一个实体:BlogSpost与3个字段:
/** * @var string * * @ORMColumn(name="body", type="blob") */ private $body; /** * @var string * */ private $rawBody; /** * @var string * */ private $bodyFormatter ;
- 这是我在BlogPostAdmin类中的格式映射器
- 但是我收到这个错误下面,当尝试创建一个帖子。
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'); } // ...
event_dispatcher、format_field、source_field、source_field_options、target_field选项不存在。已定义的选项有:"action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", " error_麻烦事","error_mapping", "extra_fields_message", "horizontal_input_wrapper_class", "horizontal_label_offset_class", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr","label_format", "label_render", "mapped", "method", "post_max_size_message", "property_path", "required", "sonata_admin", "sonata_field_description", "sonata_help", "translation_domain", "trim", "validation_groups"500内部服务器错误- UndefinedOptionsException
如何解决这个问题?
symfony 3.1.4存在很多兼容性问题,选项解析器就是其中之一。我建议尝试"formatter-bundle 4"。
也:
form:
resources:
# ...
- 'SonataFormatterBundle:Form:formatter.html.twig'
已弃用,
form_themes:
- 'SonataFormatterBundle:Form:formatter.html.twig'