terminal42 / contao-conditionalformfields

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

2.3.1 breaks conditions on second page with contao-mp_forms #44

Closed sekmedia closed 3 years ago

sekmedia commented 3 years ago

We use conditionalformfields combined with mp_forms in contao 3.5. All conditions work on first page, on second page we get an js error in line 115:

Uncaught TypeError: t.settings.previousValues.slice is not a function

We resolved this by now by rolling back to 2.3.0.

jommbee commented 3 years ago

I can confirm the problem. I have a fresh Contao 4.9 installation with the extensions mp_forms and conditional for testing. Nothing else is included. No JS or anything else. The error only comes after sending the form to step 2. but it is still there if go back to step one. Only clearing all Browser Chaches/Cookies helps to let the script work again in step one.

richardhj commented 3 years ago

Can you elaborate on the problem? My first guess is that typeof t.settings.previousValues === 'undefined'. Is there a workaround?

jommbee commented 3 years ago

I have no Idea. You can try the clear Install and watch the console: https://bughunting.eccoweb.de/ If you want access, let me know.

richardhj commented 3 years ago

Kannst du es mal mit der Datei probieren? https://pastebin.com/s50yif3j

jommbee commented 3 years ago

Wirft jetzt keinen Fehler mehr in der Console. Funktioniert initial. Nach Wechsel auf Seite zwei und dann zurück funktioniert es mal, mal nicht, das Feld zu schließen.

m-vo commented 3 years ago

@richardhj Can confirm the issue. Your fix from https://github.com/terminal42/contao-conditionalformfields/issues/44#issuecomment-726140302 works for me.

richardhj commented 3 years ago

@m-vo do you use mp_forms?

m-vo commented 3 years ago

Yes. (I only noticed the error in this combination.)

jommbee commented 3 years ago

44 works with simple text fields. With hidden checkbox menus as mandatory field there are problems. https://bughunting.eccoweb.de/

After one step back, the field cannot be deselected.

richardhj commented 3 years ago

Please checkout version 2.3.2 and provide feedback. Thanks!

m-vo commented 3 years ago

Looks good so far!

jommbee commented 3 years ago

Test case with mandatory checkbox menu does not work .

richardhj commented 3 years ago

What is the actual behavior and the intended behavior?

jommbee commented 3 years ago

User should make a selection. When clicked the fieldset Checkbox, the hidden field is displayed (mandatory). So long user can go a step forward. Then in the second step data is displayed (for example), user can click back to change data (unckech fieldset and hide mandatory field). But this is not possible now.

The mandatory field is hidden if user unchecked the fieldset Checkbox. But the form cannot be sent because the hidden mandatory field is invalid. Thus the user does not come any longer to step 2.

It also makes no difference between uncheck all fields (hidden mandatory and fieldset checkbox).

By default the hidden checkbox remains checked when it is hidden.

You can see it on example page.

jommbee commented 3 years ago

Da mein Englisch Kraut und Rüben ist, hier nochmal eine Erklärung: Was ich möchte: Ein verstecktes Checkboxmenü als Pflichfeld (field1) auf der ersten Seite (funktioniert) Die Möglichkeit von Schritt 2 zurück zu Schritt 1 zu kommen (funktioniert) Hier dann das Feld (field1) wieder zu deaktivieren (wird versteckt) Dann wieder zu Schritt 2 (funktioniert nicht): Egal ob das versteckte Feld einen Wert hat oder nicht, das Formular wird nicht gesendet.

Die Möglickeit ein Pflichfeld ein und auszublenden sollte in jedem Schritt gegeben sein, egal ob man neu mit der Eingabe beginnt, oder einen Schritt zurück geht, um Eingaben zu ändern.

richardhj commented 3 years ago

Das Ein- und Ausblenden des Feldes funktioniert ja aktuell. Aktuell schlägt die Servervalidierung fehl. Kannst du das bestätigen?

jommbee commented 3 years ago

Ja, ein und ausblenden klappt. Blendet man das Feld nach fehlgeschlagenem Sendeversuch wieder ein sieht man auch die error message "Bitte füllen Sie dieses Feld aus!". Es greift also die Validierung.

richardhj commented 3 years ago

Fixed in v2.3.3.