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

Could not load type "checkbox": class does not exist. #4903

Closed franckentien closed 6 years ago

franckentien commented 6 years ago

Environment

Sonata packages

sonata-project/admin-bundle              3.31.0 = 3.31.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.10.0 = 3.10.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  = 2.0.1  Cache library
sonata-project/classification-bundle     3.6.0  = 3.6.0  Symfony SonataClassificationBundle
sonata-project/core-bundle               3.9.0  = 3.9.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.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.4.1  = 3.4.1  Symfony Sonata / Integrate Doctrine ORM into the SonataAdm...
sonata-project/easy-extends-bundle       2.4.0  = 2.4.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0  = 1.8.0  Lightweight Exporter library
sonata-project/formatter-bundle          3.4.0  = 3.4.0  Symfony SonataFormatterBundle
sonata-project/intl-bundle               2.4.0  = 2.4.0  Symfony SonataIntlBundle
sonata-project/media-bundle              3.10.0 = 3.10.0 Symfony SonataMediaBundle
sonata-project/news-bundle               3.2.2  = 3.2.2  Symfony SonataNewsBundle
sonata-project/notification-bundle       3.3.0  = 3.3.0  Symfony SonataNotificationBundle
sonata-project/user-bundle               4.1.0  = 4.1.0  Symfony SonataUserBundle

Symfony packages

symfony/assetic-bundle     v2.8.2 = v2.8.2 Integrates Assetic into Symfony2
symfony/monolog-bundle     v3.1.2 = v3.1.2 Symfony MonologBundle
symfony/phpunit-bridge     v3.4.3 ~ v4.0.3 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.6.0 = v1.6.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.6.0 = v1.6.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.6.0 = v1.6.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.6.0 = v1.6.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.6.0 = v1.6.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.6.0 = v1.6.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1 = v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7 ~ v3.1.6 Symfony SwiftmailerBundle
symfony/symfony            v3.4.3 ~ v4.0.3 The Symfony PHP framework

PHP version

PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Subject

With the most basique projet of Symfony with the AdminBundle, the NewsBundle and all bundles require. I got an error when i wan to display the list of articles empty or not.

Steps to reproduce

Create an project, Add admin bundle, news bundle and all other bundle needed. Display the admin page and click on 'List' of news.

Expected results

The list of news or empty tab

Actual results

Error page with : Could not load type "checkbox": class does not exist.

The stack trace says 'InvalidArgumentException'

The full Stack Trace:

Symfony\Component\Form\Exception\InvalidArgumentException:
Could not load type "checkbox": class does not exist.

  at vendor\symfony\symfony\src\Symfony\Component\Form\FormRegistry.php:86
  at Symfony\Component\Form\FormRegistry->getType('checkbox')
     (vendor\symfony\symfony\src\Symfony\Component\Form\FormFactory.php:74)
  at Symfony\Component\Form\FormFactory->createNamedBuilder('value', 'checkbox', null, array('required' => false))
     (vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php:106)
  at Symfony\Component\Form\FormBuilder->create('value', 'checkbox', array('required' => false))
     (vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php:269)
  at Symfony\Component\Form\FormBuilder->resolveChildren()
     (vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php:215)
  at Symfony\Component\Form\FormBuilder->getForm()
     (vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php:221)
  at Symfony\Component\Form\FormBuilder->getForm()
     (vendor\sonata-project\admin-bundle\src\Datagrid\Datagrid.php:133)
  at Sonata\AdminBundle\Datagrid\Datagrid->buildPager()
     (vendor\sonata-project\admin-bundle\src\Datagrid\Datagrid.php:259)
  at Sonata\AdminBundle\Datagrid\Datagrid->getForm()
     (vendor\sonata-project\admin-bundle\src\Controller\CRUDController.php:157)
  at Sonata\AdminBundle\Controller\CRUDController->listAction()
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web\app_dev.php:29)
greg0ire commented 6 years ago

Can you show us the part of your admin where you configure the filters?

franckentien commented 6 years ago

This is the my full admin config file

sonata_admin:
    security:
        handler: sonata.admin.security.handler.noop

        role_admin: ROLE_ADMIN
        role_super_admin: ROLE_SUPER_ADMIN

        information:

            # Prototype
            id:                   []
        admin_permissions:

            # Defaults:
            - CREATE
            - LIST
            - DELETE
            - UNDELETE
            - EXPORT
            - OPERATOR
            - MASTER
        object_permissions:

            # Defaults:
            - VIEW
            - EDIT
            - DELETE
            - UNDELETE
            - OPERATOR
            - MASTER
            - OWNER
        acl_user_manager:     null
    title:                'Sonata Admin'
    title_logo:           bundles/sonataadmin/logo_title.png
    options:
        html5_validate:       true

        # Enable locking when editing an object, if the corresponding object manager supports it.
        lock_protection:      false

        # Enable automatic registration of annotations with JMSDiExtraBundle
        enable_jms_di_extra_autoregistration: true

    templates:
        user_block:           '@SonataAdmin/Core/user_block.html.twig'
        add_block:            '@SonataAdmin/Core/add_block.html.twig'
        layout:               '@SonataAdmin/standard_layout.html.twig'
        ajax:                 '@SonataAdmin/ajax_layout.html.twig'
        dashboard:            '@SonataAdmin/Core/dashboard.html.twig'
        search:               '@SonataAdmin/Core/search.html.twig'
        list:                 '@SonataAdmin/CRUD/list.html.twig'
        filter:               '@SonataAdmin/Form/filter_admin_fields.html.twig'
        show:                 '@SonataAdmin/CRUD/show.html.twig'
        show_compare:         '@SonataAdmin/CRUD/show_compare.html.twig'
        edit:                 '@SonataAdmin/CRUD/edit.html.twig'
        preview:              '@SonataAdmin/CRUD/preview.html.twig'
        history:              '@SonataAdmin/CRUD/history.html.twig'
        acl:                  '@SonataAdmin/CRUD/acl.html.twig'
        history_revision_timestamp:  '@SonataAdmin/CRUD/history_revision_timestamp.html.twig'
        action:               '@SonataAdmin/CRUD/action.html.twig'
        select:               '@SonataAdmin/CRUD/list__select.html.twig'
        list_block:           '@SonataAdmin/Block/block_admin_list.html.twig'
        search_result_block:  '@SonataAdmin/Block/block_search_result.html.twig'
        short_object_description:  '@SonataAdmin/Helper/short-object-description.html.twig'
        delete:               '@SonataAdmin/CRUD/delete.html.twig'
        batch:                '@SonataAdmin/CRUD/list__batch.html.twig'
        batch_confirmation:   '@SonataAdmin/CRUD/batch_confirmation.html.twig'
        inner_list_row:       '@SonataAdmin/CRUD/list_inner_row.html.twig'
        outer_list_rows_mosaic:  '@SonataAdmin/CRUD/list_outer_rows_mosaic.html.twig'
        outer_list_rows_list:  '@SonataAdmin/CRUD/list_outer_rows_list.html.twig'
        outer_list_rows_tree:  '@SonataAdmin/CRUD/list_outer_rows_tree.html.twig'
        base_list_field:      '@SonataAdmin/CRUD/base_list_field.html.twig'
        pager_links:          '@SonataAdmin/Pager/links.html.twig'
        pager_results:        '@SonataAdmin/Pager/results.html.twig'
        tab_menu_template:    '@SonataAdmin/Core/tab_menu_template.html.twig'
        knp_menu_template:    '@SonataAdmin/Menu/sonata_menu.html.twig'
    assets:
        stylesheets:

            # The default stylesheet list:
            - bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css
            - bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css
            - bundles/sonatacore/vendor/ionicons/css/ionicons.min.css
            - bundles/sonataadmin/vendor/admin-lte/dist/css/AdminLTE.min.css
            - bundles/sonataadmin/vendor/admin-lte/dist/css/skins/skin-black.min.css
            - bundles/sonataadmin/vendor/iCheck/skins/square/blue.css
            - bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css
            - bundles/sonataadmin/vendor/jqueryui/themes/base/jquery-ui.css
            - bundles/sonatacore/vendor/select2/select2.css
            - bundles/sonatacore/vendor/select2-bootstrap-css/select2-bootstrap.min.css
            - bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css
            - bundles/sonataadmin/css/styles.css
            - bundles/sonataadmin/css/layout.css
            - bundles/sonataadmin/css/tree.css
            - bundles/sonataadmin/css/colors.css

        # stylesheet paths to add to the page in addition to the list above
        extra_stylesheets: []

        # stylesheet paths to remove from the page
        remove_stylesheets: []

        javascripts:

            # The default javascript list:
            - bundles/sonatacore/vendor/jquery/dist/jquery.min.js
            - bundles/sonataadmin/vendor/jquery.scrollTo/jquery.scrollTo.min.js
            - bundles/sonatacore/vendor/moment/min/moment.min.js
            - bundles/sonataadmin/vendor/jqueryui/ui/minified/jquery-ui.min.js
            - bundles/sonataadmin/vendor/jqueryui/ui/minified/i18n/jquery-ui-i18n.min.js
            - bundles/sonatacore/vendor/bootstrap/dist/js/bootstrap.min.js
            - bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js
            - bundles/sonataadmin/vendor/jquery-form/jquery.form.js
            - bundles/sonataadmin/jquery/jquery.confirmExit.js
            - bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js
            - bundles/sonatacore/vendor/select2/select2.min.js
            - bundles/sonataadmin/vendor/admin-lte/dist/js/app.min.js
            - bundles/sonataadmin/vendor/iCheck/icheck.min.js
            - bundles/sonataadmin/vendor/slimScroll/jquery.slimscroll.min.js
            - bundles/sonataadmin/vendor/waypoints/lib/jquery.waypoints.min.js
            - bundles/sonataadmin/vendor/waypoints/lib/shortcuts/sticky.min.js
            - bundles/sonataadmin/Admin.js
            - bundles/sonataadmin/treeview.js
            - bundles/sonataadmin/sidebar.js

        # javascript paths to add to the page in addition to the list above
        extra_javascripts: []

        # javascript paths to remove from the page
        remove_javascripts: []

    persist_filters:      false
    show_mosaic_button:   true
greg0ire commented 6 years ago

That's great, but can you show us the part of your admin (class) where you configure the filters?

franckentien commented 6 years ago

I have never create an admin class.

greg0ire commented 6 years ago

It says here you are on the list action though: Sonata\AdminBundle\Controller\CRUDController->listAction(). What is your current URL?

greg0ire commented 6 years ago

I got an error when i wan to display the list of articles empty or not.

Oh I see, you seem to be having an issue with the news bundle

greg0ire commented 6 years ago

I think your issue comes from this line: https://github.com/sonata-project/SonataNewsBundle/blob/3.x/src/Admin/PostAdmin.php#L214

Closing this, please open an issue on the news bundle, or better, make a PR to fix it.

darius-v commented 6 years ago

I had same issue when doing by documentation

Admin version from composer.json: "sonata-project/doctrine-orm-admin-bundle": "^3.1.7",

https://sonata-project.org/bundles/doctrine-orm-admin/3-x/doc/reference/filter_field_definition.html

Documentation shows to use 'field_type' => 'checkbox'

but I had to use like there https://github.com/sonata-project/SonataNewsBundle/blob/3.x/src/Admin/PostAdmin.php#L214

'field_type' => CheckboxType::class

to not get this error.

jordisala1991 commented 6 years ago

Feel free to contribute to docs :)