Skip to content

ElFinderType in EasyAdmin 4.x (with Symfony 6.x) form shows only a text field #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Baloobear opened this issue Jan 17, 2022 · 3 comments

Comments

@Baloobear
Copy link

Hello everyone.

Describe the bug

When I try to integrate a form field of the type ElFinderType in my EasyAdmin crud controller I only get a simple text field without any function.

Even trying to integrate the infos related to https://stackoverflow.com/questions/64480120/using-elfinder-on-symfony-i-cant-select-images or #406 (incl. overwriting the templates and converting the given infos to the updated EasyAdmin 3.x/4.x configuration) does not help in any way. It also seems that the widget template (neither the original one or the own in templates/bundles/FMElFinderBundle/Form) seems not to be used.

To Reproduce

Here's the code I'm using:

CrudController

// ProjectCrudController.php
// ...
public function configureFields(string $pageName): iterable
{
    // ...
    yield Field::new('introImage', 'Intro Image')
        ->setFormType(ElFinderType::class)
        ->setFormTypeOptions([
            'instance' => 'projects_default',
            'enable' => true,
        ])
        ->onlyOnForms()
    ;
    // ...
}

fm_elfinder.yaml

fm_elfinder:
    instances:
        projects_default:
            locale: 'de'
            editor: form
            visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg']
            connector:
                roots:
                    projects:
                        driver: LocalFileSystem
                        path: images/projects
                        upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                        upload_max_size: 5M

Additional context

Used packages/libs:

  • Symfony 6.0.2
  • EasyAdmin 4.0.2

Any help is appreciated.

Kind regards,
Dennis

@helios-ag
Copy link
Owner

hi @Baloobear, it would be nice if you check what printed in browser console.

@Baloobear
Copy link
Author

Hi @helios-ag,

after there was no browser console output I did a quick check with a standard (non EasyAdmin) form including a field of the type ElFinder::class which works as expected so I took a deeper look into my config.

Finally I got the reason why the widget template hasn't been loaded: the widget form type template must be added to the CRUD controller (similar to the EasyAdmin 2 config).

I did it with the following code in my CrudController:

public function configureCrud(Crud $crud): Crud
{
    return $crud
        // ...
        ->addFormTheme('@FMElfinder/Form/elfinder_widget.html.twig')
    ;
}

With this done the form renders the correct ElFinder form widget and one can start from this point to change the widget template to fit the personal needs etc.

So maybe you can extend the docs with a section for EasyAdmin 3.x/4.x with this info.

Greetings,
Dennis

@helios-ag
Copy link
Owner

@Baloobear thanks for sharing your solution! Appreciate that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants