Skip to content

"res is not defined" error #49

@WardVandevoort

Description

@WardVandevoort

Hi,

I am using v2.0.126 of this package in a Symfony 5.4 project using EasyAdmin.

In my EasyAdmin crud controller I have the following field config for the EasyMediaField:

public function configureFields(string $pageName): iterable
    {
        return [
            EasyMediaField::new('image', 'Image')
                // Apply restrictions by mime-types
                ->setFormTypeOption(
                    'restrictions_uploadTypes',
                    [
                        'image/jpeg',
                        'image/png',
                        'image/gif'
                    ]
                )
                // Apply restrictions to upload size in MB
                ->setFormTypeOption('restrictions_uploadSize', 1.0)
                ->setFormTypeOption('editor', true)
                ->setFormTypeOption('upload', true)
                ->setFormTypeOption('bulk_selection', true)
                ->setFormTypeOption('move', true)
                ->setFormTypeOption('rename', true)
                ->setFormTypeOption('metas', true)
                ->setFormTypeOption('delete', true)
        ];
    }

As you can see I have added restrictions on mime-type and upload size.

However when I upload a file with a mime-type that is not allowed, or when I upload a file larger than 1MB, nothing seems to happen.

When I open the console in devtools I do get the following error messages:

Image

At the bottom of the screenshot you can see "Uncaught ReferenceError: res is not defined", when I go to the file where the error is thrown I see the following.

Image

There seems to be an issue with displaying the error messages to the user, specifically for these restrictions.

Could you please have a look at this?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions