sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Checkboxes do look odd after Ajax-call when using sonata_type_collection inline-tables. #4147

Closed syeo66 closed 8 years ago

syeo66 commented 8 years ago

Environment

Sonata packages

$ composer show sonata-project/*
sonata-project/admin-bundle                3.8.0
sonata-project/block-bundle                3.2.0
sonata-project/cache                       1.0.7
sonata-project/core-bundle                 3.1.1
sonata-project/datagrid-bundle             2.2
sonata-project/doctrine-extensions         1.0.2
sonata-project/doctrine-orm-admin-bundle   3.1.0
sonata-project/doctrine-phpcr-admin-bundle dev-master 829753e
sonata-project/easy-extends-bundle         2.1.10
sonata-project/exporter                    1.7.0
sonata-project/google-authenticator        1.0.2
sonata-project/translation-bundle          2.0.2
sonata-project/user-bundle                 3.0.1

Symfony packages

$ composer show symfony/*
symfony/assetic-bundle     v2.8.0  Integrates Assetic into Symfony2
symfony/intl               v3.1.4  A PHP replacement layer for the C intl e...
symfony/monolog-bundle     2.11.1  Symfony MonologBundle
symfony/phpunit-bridge     v2.8.11 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.2.0  Symfony polyfill backporting apcu_* func...
symfony/polyfill-intl-icu  v1.2.0  Symfony polyfill for intl's ICU-related ...
symfony/polyfill-mbstring  v1.2.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.2.0  Symfony polyfill backporting some PHP 5....
symfony/polyfill-php55     v1.2.0  Symfony polyfill backporting some PHP 5....
symfony/polyfill-php56     v1.2.0  Symfony polyfill backporting some PHP 5....
symfony/polyfill-php70     v1.2.0  Symfony polyfill backporting some PHP 7....
symfony/polyfill-util      v1.2.0  Symfony utilities for portability of PHP...
symfony/security-acl       v3.0.0  Symfony Security Component - ACL (Access...
symfony/swiftmailer-bundle v2.3.11 Symfony SwiftmailerBundle
symfony/symfony            v2.8.11 The Symfony PHP framework

PHP version

$ php -v
PHP 5.6.26 (cli) (built: Sep 21 2016 04:57:02)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Subject

Checkboxes do look odd after Ajax-call when using sonata_type_collection inline-tables.

icheck_before_ajax

checkboxes_after_ajax

greg0ire commented 8 years ago

Thanks for reporting this @syeo66 ! Can you please compare the html in both cases, and find the template(s) involved? They should appear in the symfony profiler, or maybe just use grep to find them. Also, you kind find the profile for the ajax query in the symfony profiler by using the built-in form there is.

syeo66 commented 8 years ago

Well, I tried to find as many information as I could. The HTML (extracted from Chromes inspector - so after any Javascript-Processing took place) looks like this at first (correct version):

<td class="sonata-ba-td-s57ea5dfdce73a_normtables-_delete">
    <div class="checkbox">
        <label>
            <div class="icheckbox_square-blue">
                <input type="checkbox" id="s57ea5dfdce73a_normtables_0__delete" name="s57ea5dfdce73a[normtables][0][_delete]" value="1" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
                </ins>
            </div>
            <span class="control-label__text">Delete</span>
        </label>
    </div>
</td>

The code after the Ajax call looks like this:

<td class="sonata-ba-td-s57ea5dfdce73a_normtables-_delete">
    <div class="checkbox">                                                               
        <label>
            <input type="checkbox" id="s57ea5dfdce73a_normtables_0__delete" name="s57ea5dfdce73a[normtables][0][_delete]" value="1">
            <span class="control-label__text">Delete</span>
        </label>
    </div>
</td>

The involved templates are in both cases those two: SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_one_to_many.html.twig SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_one_association_script.html.twig

However it really seems as if the iCheck script needs to get called again after retrieving the content by ajax.

(For some reason I can't make the HTML-Code to show up correctly) html_examples.txt