getgrav / grav-plugin-form

Grav Form Plugin

Home Page:http://getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dropzone assets added for every file field

hughbris opened this issue · comments

The file field template adds the same CSS and JS for every file upload field, so a form with several of these has unnecessary repetition.

I experimented with moving the assets.css() invocation to the form layout template and that removed the repetition, though it will still repeat if there were more than one form on a page, so not a proper solution.

Another problem caused by the CSS rendering is that it does not accommodate asset priorities. I can't easily override CSS from these files in a custom stylesheet because the block is not deferred and has no priority. Do the CSS assets need to be in a 'form' group? It seems if they were in the default group, then at least they could be set to the default or a high priority, and with deferred rendering. As I understand it, this would remove the need to call assets.css() in the file template and resolves the problem described at the top of this issue.

I wonder if this was originally built before deferred assets and they would provide a solution to this problem. We'd have make a lot of assumptions about the theme's base template though (that it has a 'bottom' js block, and that this and its other main asset blocks use deferred).