sonata-project / SonataBlockBundle

Symfony SonataBlockBundle
https://docs.sonata-project.org/projects/SonataBlockBundle
MIT License
413 stars 142 forks source link

Using CKEditorType::class results in text that is editable but vanishes after save #485

Closed patrickmaynard closed 4 years ago

patrickmaynard commented 6 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'

sonata-project/admin-bundle              3.23.0             3.32.0          The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.2              3.12.0          Symfony SonataBlockBundle
sonata-project/cache                     1.0.7              1.0.7           Cache library
sonata-project/cache-bundle              2.3.1              2.4.1           This bundle provides caching serv...
sonata-project/classification-bundle     3.3.1              3.6.1           Symfony SonataClassificationBundle
sonata-project/core-bundle               3.4.0              3.9.1           Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1              2.3.1           Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2              1.0.2           Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.1.7              3.4.2           Symfony Sonata / Integrate Doctri...
sonata-project/easy-extends-bundle       2.2.0              2.5.0           Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.7.1              1.8.0           Lightweight Exporter library
sonata-project/formatter-bundle          3.2.2              3.4.1           Symfony SonataFormatterBundle
sonata-project/intl-bundle               2.2.4              2.4.0           Symfony SonataIntlBundle
sonata-project/media-bundle              3.6.0              3.11.0          Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0              3.4.0           Symfony SonataNotificationBundle
sonata-project/page-bundle               3.x-dev d66da16    3.x-dev ca9be6c This bundle provides a Site and P...
sonata-project/seo-bundle                2.2.0              2.5.1           Symfony SonataSeoBundle
sonata-project/timeline-bundle           3.1.1              3.3.0           Integrates SpyTimelineBundle into...
sonata-project/translation-bundle        2.1.1              2.3.0           SonataTranslationBundle
sonata-project/user-bundle               dev-master fca7672 3.x-dev 9ce7143 Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.1.0 v3.1.2 Symfony MonologBundle
symfony/phpunit-bridge     v3.3.9 v4.0.5 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.5.0 v1.7.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.5.0 v1.7.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.5.0 v1.7.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.5.0 v1.7.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP ver...
symfony/polyfill-php70     v1.5.0 v1.7.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP ver...
symfony/polyfill-php72     v1.5.0 v1.7.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP ver...
symfony/polyfill-util      v1.5.0 v1.7.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0 v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.3 v3.2.0 Symfony SwiftmailerBundle
symfony/symfony            v3.3.6 v3.3.6 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.10 (cli) (built: Oct 10 2017 01:30:46) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.10, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

Subject

Steps to reproduce

Open TextBlockService.php.

Replace

    $formMapper->add('settings', 'sonata_type_immutable_array', 
        array(
        'keys' => array(
            array(
                'content', 'textarea', 
                array()
            ),
        ),
    ));

with

    $formMapper->add('settings', 'sonata_type_immutable_array',
        array(
        'keys' => array(
            array(
                'content',
                CKEditorType::class,
                array(),
            )
        ),
    ));

... and create a new block, then edit the default text in the resulting CKEditor. Save text. You will find that the text does not save but is replaced again with the default text.

Expected results

New text saves and is visible when the block's editing interface is refreshed.

Actual results

Text is again replaced with 'Insert your custom content here.'

OskarStark commented 6 years ago

Did you try to use SonataFormatterBundle?

patrickmaynard commented 6 years ago

Hi @OskarStark -- thanks for commenting. I did not try to use SonataFormatterBundle. Is there a piece of documentation somewhere that describes how to use that bundle along with the block bundle?

nicolas-joubert commented 5 years ago

Hello @patrickmaynard, i've fix same issue with ['input_sync' => true] option.

core23 commented 5 years ago

Did this work for you @patrickmaynard ?

Feel free to close

core23 commented 5 years ago

IMO this bug is not related to the block bundle. The CKEditorType type needs two field

christophe-bardzinsky commented 4 years ago

Hi, is there someone who found the solution? I have the same problem.

mirlo06 commented 4 years ago

@christophe-bardzinsky you can try this, it works for me :

        $formMapper
                ->add('description', CKEditorType::Class, array(
                    'config' => array(
                        'uiColor' => '#ffffff', 'toolbar' => 'full', 'required' => true
                    ),'input_sync' => true
                ));