helios-ag / FMElfinderBundle

:file_folder: ElFinderBundle provides ElFinder integration with TinyMCE, CKEditor, Summernote editors
MIT License
275 stars 128 forks source link

set the homeFolder value like 'mainfolder/subfolder' (in twig path function) throw an InvalidParameterException exception #490

Open kegilko opened 1 year ago

kegilko commented 1 year ago

Firstly, thank you for this very usefull lib !

Describe the bug

From symfony 6 (with the package 'helios-ag/fm-elfinder-bundle' version 12.2.1), I overrided 'elfinder_widget.html.twig' twig template. When I set the 'homeFolder' paramater with a string value containing a subfolder path, I got an Exception because the value of 'homeFolder' must not contain a char '/'.

To Reproduce

// content of the overrided 'elfinder_widget.html.twig' file
{% block elfinder_widget %}
    <input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-type="elfinder-input-field" />
    {% if enable and instance is defined %}
        <script type="text/javascript" charset="utf-8">
          live('click', '[data-type="elfinder-input-field"]', function (event) {
            let id = this.getAttribute('id');

            // I want to open elfinder on the directory 'criteres_memes', this directory is in the 'articles' directory, and the 'articles' directory is in the main directory 'body'
            var childWin = window.open("{{path('elfinder', {'instance': instance, 'homeFolder': 'body/articles/criteres_memes' })}}?id="+id, "popupWindow", "height=450, width=900");
            // I tried also with '/body/articles/criteres_memes' with begin slash, but the same exception occurs
          });
          // ...
        </script>
    {% endif %}
{% endblock %}

image

My question : is this a bug ? or maybe I must use a specific char when I want to use a path with subdirectories ? I searched everywhere where the regex '[^/]++' is defined (and get maybe more explanations), but I didn't find it !

Additional context

I don't know if its information is usefull, but I don't use easyadmin, I just installed the package 'helios-ag/fm-elfinder-bundle' for the usefull 'ElFinderType' field in my form class ;)

another information : I needed to override the template for an another issue (the elfinder popup didn't open when I create a content with a CollectionType of another entity )

Thanks for any help !

helios-ag commented 1 year ago

hi @kegilko, sorry for belated answer seems its your case https://symfony.com/doc/6.3/routing.html#slash-characters-in-route-parameters Override bundle's routing file in your case