Do not identify modal

  symfony4, twig

After updating from Symfony 2.X to Symfony 4.4 and verifying the operation, I found that Twig does not recognize modal.
Since it does not recognize modal, it will be displayed even when the code that is not displayed in modal in the if statement is displayed in modal.
When I tried "if modal is empty", the code in the if statement was displayed, so it seems that the modal is not passed.
The code that passes the modal has changed with the Symfony update. This may have an effect.
Do you have any idea?

Old_code

    <div id="imageDialog" title="Image management">
        {{ render(controller("AppBundle:Shop/Image:manager", {"modal": true})) }}
    </div>

Changed_code

    <div id="imageDialog" title="Image management">
        {{ render(controller("AppBundleControllerShopImageController::managerAction", {"modal": true})) }}
    </div>

Code in question

    <div class="tabpanel selected" id="imageFolder" >
        <div class="tabcontent">
            <div class="operations">
                {% if not modal %}
                    <div class="pull-right">
                        <form method="post" action="{{ path('app_shop_image_delete') }}">
                            <input type="hidden" name="methods" value="delete">
                            <input type="hidden" name="_csrf_token" value="{{ csrf_token("authenticate") }}">
                            <input type="hidden" name="ids" value="[]">
                            <button type="submit" class="delete btn btn-danger"><i class="icon-trash"></i> Delete</button>
                        </form>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>

ImageController

     *
     * @Method("GET")
     * @Route("/manager")
     *
     * @Template("@AppBundle/Shop/Image/manager.html.twig")
     */
    public function managerAction(Request $request)
    {
        $routeParams = $request->get('_route_params');
        $uploadUrl = $this->generateUrl("app_shop_image_save");
        return array(
            'modal' => isset($routeParams["modal"]) ? $routeParams["modal"] : false,
            'form'  => $this->createUploadForm($uploadUrl)->createView(),
        );
    }

Source: Symfony4 Questions

LEAVE A COMMENT