plain-solutions-gmbh / kirby-form-block-suite

This form plugin for Kirby offers you maximum flexibility and usability. It can be used as a block anywhere you needed. This repository replaces the obsolete version 2.0.
Other
38 stars 11 forks source link

Incompatibility with kirby-minify-html + possible fix #15

Closed rantonse closed 1 year ago

rantonse commented 1 year ago

Hi, and thanks for the plugin!

There is an incompatabilty with afbora/kirby-minify-html.

To reproduce, I added the latest versions of both plugins to the starter kit

After adding a form to the home page, and clicking send without any fields filled out, you get both a 404 error and a parse error.

The reason for the error is that the kirby-minify-html plugin removes comments. After some experimentation, I found out that the kirby-minify-html plugin does not remove conditional comments (with the <!--[if IE]> syntax), so a fix would perhaps be to change the comments syntax?

I tried that with success, and only two files need to be slightly changed:

The changes I did are here:

Basically, these are the changes to the validation.php file:

Then, in index.php, changing the regexp

Do you see any downsides to this change?

plain-solutions-gmbh commented 1 year ago

Thanks for your suggestion. Your example breaks the Validation because the JSON outputs HTML and the comment falls out. I hope i explained clearly. If i uncomment the oncoming JSON, the validation will work. But i don't know, if the minify will remove that json. I fixed it in 3.4.7. Can you test it? If not: Probably the minify-plugin has an option to exclude i specific url.

Just let me know

rantonse commented 1 year ago

I am not sure I completely understand. I tried the 3.4.7 fix on a fresh installation, but the error remains.

On my end, I got it to work by wrapping the middle <?php ?> part in validation.php within <!--[ and ]-->. In other words, <?php ... ?> becomes <!--[<?php ... ?>]-->. For the regular expression in index.php, I replaced (.*?) with \s\<\!--\[(.*?)\]--\>\s.

I am not sure if this is a good idea, but this is my current workaround. :)

plain-solutions-gmbh commented 1 year ago

That will break the inline validation. (Autovalidation during form fill). You can check it in your console:

  1. Open Devtool console
  2. Enter a text in a field
  3. Go to another field

Your code will probably case an error. Because inside '' will be a JSON with HTML-Code. Which break the comments. Can you confirm that?

plain-solutions-gmbh commented 1 year ago

Since I haven't heard anything more, it seems to me that a solution to this problem has been found. I'il close this issue.