Skip to content
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

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

Open
spacecodeur opened this issue Jan 28, 2023 · 1 comment

Comments

@spacecodeur
Copy link

spacecodeur commented Jan 28, 2023

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

  • override the 'elfinder_widget.html' template
  • set the value 'homeFolder' with a string containing a char '/' like this :
// 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 %}
  • and you get the pretty exeption bellow :

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
Copy link
Owner

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

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