четверг, 8 июля 2021 г.

[Sylius] GridHelper::renderGrid() must be an instance of Sylius\Component\Grid\View\GridView, instance of Pagerfanta\Pagerfanta - how to fix

 It means you forgot to put `grid: gridname` into your route configuration. For example:

admin_user_index:

    path: /users

    defaults:

        _controller: app.controller.user::indexAction

        _sylius:

            template: "@AdminBundle/grid/index.html.twig"

            grid: admin_user

воскресенье, 4 июля 2021 г.

[Symfony] how to modify data_class object setting logic

 When you need extra manipulations to object data population in form (for example, you need to resolve whether is entered user email is already registered and put existing user object or it needs to create a new user), you might want to set data_class with closure, but there isn't such option.

The right way is to use https://symfony.com/doc/4.4/form/data_mappers.html Data Mappers