Sonataadminbundle: Conflict with the ckeditor's form variable `inline`

Created on 25 Jun 2019  路  8Comments  路  Source: sonata-project/SonataAdminBundle

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
# sonata-project/admin-bundle              3.49.1
# sonata-project/block-bundle              3.15.0
# sonata-project/cache                     2.0.1
# sonata-project/core-bundle               3.17.0
# sonata-project/datagrid-bundle           2.5.0
# sonata-project/doctrine-extensions       1.3.0
# sonata-project/doctrine-orm-admin-bundle 3.9.0
# sonata-project/exporter                  2.0.1

Symfony packages

$ composer show --latest 'symfony/*'
# symfony/asset                 v4.3.1
# symfony/browser-kit           v4.3.1
# symfony/cache                 v4.3.1
# symfony/config                v4.3.1
# symfony/console               v4.3.1
# symfony/contracts             v1.1.3
# symfony/css-selector          v4.3.1
# symfony/debug                 v4.3.1
# symfony/debug-bundle          v4.3.1
# symfony/debug-pack            v1.0.7
# symfony/dependency-injection  v4.3.1
# symfony/doctrine-bridge       v4.3.1
# symfony/dom-crawler           v4.3.1
# symfony/dotenv                v4.3.1
# symfony/event-dispatcher      v4.3.1
# symfony/expression-language   v4.3.1
# symfony/filesystem            v4.3.1
# symfony/finder                v4.3.1
# symfony/flex                  v1.2.7
# symfony/form                  v4.3.1
# symfony/framework-bundle      v4.3.1
# symfony/http-client           v4.3.1
# symfony/http-foundation       v4.3.1
# symfony/http-kernel           v4.3.1
# symfony/inflector             v4.3.1
# symfony/intl                  v4.3.1
# symfony/maker-bundle          v1.11.6
# symfony/mime                  v4.3.1
# symfony/monolog-bridge        v4.3.1
# symfony/monolog-bundle        v3.3.1
# symfony/options-resolver      v4.3.1
# symfony/orm-pack              v1.0.6
# symfony/panther               v0.4.1
# symfony/phpunit-bridge        v4.3.1
# symfony/polyfill-intl-icu     v1.11.0
# symfony/polyfill-intl-idn     v1.11.0
# symfony/polyfill-mbstring     v1.11.0
# symfony/polyfill-php72        v1.11.0
# symfony/polyfill-php73        v1.11.0
# symfony/process               v4.3.1
# symfony/profiler-pack         v1.0.4
# symfony/property-access       v4.3.1
# symfony/property-info         v4.3.1
# symfony/routing               v4.3.1
# symfony/security-acl          v3.0.2
# symfony/security-bundle       v4.3.1
# symfony/security-core         v4.3.1
# symfony/security-csrf         v4.3.1
# symfony/security-guard        v4.3.1
# symfony/security-http         v4.3.1
# symfony/serializer            v4.3.1
# symfony/serializer-pack       v1.0.2
# symfony/stopwatch             v4.3.1
# symfony/swiftmailer-bundle    v3.2.7
# symfony/templating            v4.3.1
# symfony/test-pack             v1.0.5
# symfony/translation           v4.3.1
# symfony/twig-bridge           v4.3.1
# symfony/twig-bundle           v4.3.1
# symfony/validator             v4.3.1
# symfony/var-dumper            v4.3.1
# symfony/var-exporter          v4.3.1
# symfony/web-link              v4.3.1
# symfony/web-profiler-bundle   v4.3.1
# symfony/web-server-bundle     v4.3.1
# symfony/webpack-encore-bundle v1.6.0
# symfony/yaml                  v4.3.1

FOSCKEditorBundle version

$ composer show --latest 'friendsofsymfony/ckeditor-bundle*'
# friendsofsymfony/ckeditor-bundle 2.1.0

PHP version

$ php -v
# 7.3

Subject

When I want to use CKEditorType in inline editable collection with the inline option, ckeditor is always rendered as inline editor.

Steps to reproduce

Add a field with following field description options to your admin's FormMapper

    ->add(
        'oneToManyFieldName',       # 1) make an admin for this field, which is
                                    #    contains a field using ckeditor type.
        CollectionType::class,
        [],
        [
            'edit' => 'inline',     # 2) use `edit` option.
            'inline' => 'natural',  # 3) and use `inline` option with any value.
        ]
    )

Expected results

Rendering ckeditor form with only passed options where in FormMapper. So, when does not passing any inline option, ckeditor form should not behave like an inline configurated ckeditor form.

Actual results

An inline configurated ckeditor form.

The source of the problem

Directly passed inline variable to nested field in this line:

https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/Association/edit_one_to_many_inline_tabs.html.twig#L42

bug pending author

All 8 comments

Hi @emr!
I'm trying to reproduce your issue, but I don't see any changes on the CKEditor layout.
How it looks and how it should look like?

In shortly...

When using collection type with this options:

[
    'edit' => 'inline',
    'inline' => 'natural',
]

Result:

Result with <code>inline: natural</code>

(I have dumped inline variable in ckeditor layout)

And when using collection type without inline option:

Result without any option

This result is as it should be.

Thank you for the feedback.
I was able to reproduce what you're describing passing "natural" as value for inline option. Using "table", I see the right layout. Could you confirm please?

Yes, because when you set inline option's value to table, Sonata rendering only form widget without any variable.

You can see here:

 {{ form_widget(nested_field) }}

https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/Association/edit_one_to_many_inline_table.html.twig#L48

But when using inline with all value except table, occurring the problem what we talking about.

{{ form_row(nested_field, {
    'inline': 'natural',
    'edit'  : 'inline'
}) }}

https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/Association/edit_one_to_many_inline_tabs.html.twig#L42

@emr, would you like to work on a solution for this?

Of course, I will contribute when I find some time.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hi @emr, what was your solution for this ?

Removing 'inline': 'natural' seems to fix the problem, but maybe that's not the best solution. I don't really know what is doing this option...

Was this page helpful?
0 / 5 - 0 ratings