1. Installation¶
First, you need to install FOSCKEditorBundle.
Install SonataFormatterBundle:
1 | composer require sonata-project/formatter-bundle
|
Register the bundles in bundles.php
file:
// config/bundles.php
return [
// ...
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Sonata\FormatterBundle\SonataFormatterBundle::class => ['all' => true],
];
You have to install Ckeditor:
1 | bin/console ckeditor:install
|
and install Symfony assets:
1 | bin/console assets:install
|
2. Configuration¶
Add Twig configuration:
1 2 3 4 5 6 7 8 | # config/packages/twig.yaml
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- '@SonataFormatter/Form/formatter.html.twig'
|
Now add SonataFormatter configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # config/packages/sonata.yaml
sonata_formatter:
default_formatter: text
formatters:
text:
service: sonata.formatter.text.text
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
richhtml:
service: sonata.formatter.text.raw
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.formatter.twig.media # do not add this unless you are using media bundle.
|