Using ElFinder on Symfony: I can’t select images

I want to use ElFinder as my file manager in my Symfony project. I followed the doc on GitHub. In my routes.yaml:

elfinder:
     resource: '@FMElfinderBundle/Resources/config/routing.yaml'

security.yaml

- { path: ^/efconnect, role: [ROLE_USER] }
- { path: ^/elfinder, role: [ROLE_USER] }

And finally on fm_elfinder.yaml

fm_elfinder:
    instances:
        default:
            locale: '%locale%' # defaults to current request locale
            editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
            connector:
                roots:
                    uploads:
                        driver: LocalFileSystem
                        path: uploads
                        upload_max_size: 2M

Then I added it on a Admin element on Sonata, like this:
protected function configureFormFields(FormMapper $formMapper)

{
    $formMapper
        ->with('Contenu')
        ->add('published', CheckboxType::class, ['required' => false, 'label' => 'Publier'])
        ->add('title', TextType::class, ['required' => true, 'label' => 'Titre'])
        ->add('textLink', TextType::class, ['required' => true, 'label' => 'Texte du lien'])
        ->add('media', ElFinderType::class, array(
            'label' => 'Photo',
            'enable' => true,
            'required' => true,
            'instance' => 'default',
            'attr' => array('class' => 'form-control')
            )
        )
        ->end();
}

Then I go on Sonata Admin, and when I try to add an image, a window open, I added an jpeg but then when i click on it, nothing seems to happen. Like, I can select it but my window stay open and my field doesn’t fill up with the name of the image.
Thanks for your help.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *