terminal42 / contao-conditionalformfields

Display form fields conditionally in Contao Open Source CMS
MIT License
18 stars 12 forks source link

JS Error with RockSolid Antispam #83

Closed chibko closed 10 months ago

chibko commented 1 year ago

Hi,

Sometimes, JS error occurs on FE on form with rocksolid antispam extension installed. The browser console says "SyntaxError: identifier starts immediately after numeric literal". I dig it and found that the problem is rocksolid antispam create a invisible field with a random name witch may sometines start with digit and cause the conditionalformfields js script to fail. Can you solve this issue ? Regards, Stéphane

chibko commented 1 year ago

I saw that the js check if the key includes '-' or '['. May be it should check if the key start with something other than letter ?

formData.forEach(function (value, key) { if (String(key).includes('-') || String(key).includes('[')) { console.warn(terminal42/contao-conditionalformfields: skipping "${key}", special characters [-] and brackets are not supported in JavaScript variables.); } else { fnBody += const ${key} = values.get('${key}');; } });

chibko commented 11 months ago

ausi @ madyourday suggests this fix https://github.com/madeyourday/contao-rocksolid-antispam/issues/9

aschempp commented 10 months ago

Fixed in 87ac1fc63ea8c7f8a2bc858b59cd26cb74687691