I'm using symfony 3.1.4 and install SonataAdminBundle, SonataFormatterBundle. I'm having troubles using the Sonata Formatter Bundle.
Install SonataFormatterBundle by this guide:
I have an Entity: BlogSpost with 3 fields:
/** * @var string * * @ORM\Column(name="body", type="blob") */ private $body; /** * @var string * */ private $rawBody; /** * @var string * */ private $bodyFormatter ;
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'); } // ...
The options "event_dispatcher", "format_field", "source_field", "source_field_options", "target_field" do not exist. Defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "horizontal_input_wrapper_class", "horizontal_label_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 Internal Server Error - UndefinedOptionsException
How do I resolve this issue?
There are a lot of compatibility problems with symfony 3.1.4, option resolver is one of them . I recommend to try 'formatter-bundle 4.x-dev', where it's fixed among other issues.
Also:
form:
resources:
# ...
- 'SonataFormatterBundle:Form:formatter.html.twig'
is deprecated and
form_themes:
- 'SonataFormatterBundle:Form:formatter.html.twig'
should be used instead.