EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Cannot use renderView to add content to Body in Assets in CRUD Controller

Open bytes-max opened this issue 2 years ago • 1 comments

Describe the bug I am trying to add content to the body section via assets:


    public function configureAssets(Assets $assets): Assets
    {
        $assets = parent::configureAssets($assets);
        $assets->addJsFile('static/js/validation/identifier-field-validation.js');

        $content = $this->environment->render('backend/projects/number-range-modal.html.twig', [
            'configProvider' => $this->configProvider,
        ]);
        $assets->addHtmlContentToBody($content);

        return $assets;
    }

However, this leads to the famous Variable "ea" does not exist. error page. I can confirm that the error happens with both extra injected environment variable, and without (directly calling renderView as its a regular controller and thus, has it available).

It also is not working when manually providing ea variable to payload. Its just gone in the second rendering attempt.

I am yet checking how to solve this bug, but maybe someone has the solution at hand already.

bytes-max avatar Aug 16 '24 13:08 bytes-max

Turns out that this solution has worked for me: https://github.com/EasyCorp/EasyAdminBundle/issues/5986#issuecomment-1912829871

bytes-max avatar Aug 16 '24 13:08 bytes-max