• Resolved Mad Max

    (@mad_max)


    Here is my form export:

    https://drive.google.com/file/d/1WO_2iO723Ov1Y7Zt1yF6B2rFkyZwYJUi/view?usp=share_link

    Hidden required fields depend on a checkbox that has a display condition itself. If the user chooses not to use the “ONLINE” payment method in {radio-2}, the checkbox {checkbox-1} is displayed as already checked. Then, if the user unchecks it, required hidden fields are displayed.

    I’ve found a post in your forum from three years ago, which seems to match my problem, but I can’t figure out how to use the suggested code or if there is another workaround for such situations.

    thanks, Daniele.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @mad_max,

    I hope you are doing well today!

    You can apply the solution as mu-plugin which is instructed in
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Basically, go to /wp-content/mu-plugins folder (create if you don’t have one) then create a php file with any name, such as forminator-hidden-field-fix.php and copy the contents in https://gist.github.com/wpmudev-sls/8975c5339b997bffadced3fdebcf1b5e

    After that paste the code completely into the file and save it, then test again.

    Please let us know how it goes.

    Kind regards,
    Zafer

    Thread Starter Mad Max

    (@mad_max)

    Hi Zafer (@wpmudevsupport15),
    thanks for the quick reply!

    In the forum post I’ve linked above, your staff hint was to use the code as a guide, so I figured it needs to be customized in some way to work. Actually I already applied the code in the theme functions.php file with no success.

    I added an error_log() statement at the very start of the wpmudev_forminator_fix_can_not_submit_on_nest_required_fields_func() to be sure it runs and so it does, but when I submit the payment with Paypal, the form notifies errors on hidden fields as you can see looking to the ajax response here and here

    I can post the page url with the form, if you need to see it in action, and share sandbox paypal credentials of a test buyer to test the process.

    Regards,
    Daniele.

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @mad_max,

    Hope you are doing good today.

    I checked your from export. However, I’m a bit lost with what exact issue you are originally facing.

    If the user chooses not to use the “ONLINE” payment method in {radio-2}, the checkbox {checkbox-1} is displayed as already checked. Then, if the user unchecks it, required hidden fields are displayed.

    I tested your form by selecting the “Offline: Assegno al corriere” option from the Radio field and with the “Spedisci all’indirizzo di fatturazione” checkbox checked, and the form got submitted.

    I also tried the same by unchecking the checkbox, and still, the form got submitted.

    So I’m a bit lost with the exact issue you are facing so that we can check what could be suggested.

    Since the form isn’t in English, maybe I’m missing out on anything. However, please provide the steps to replicate the current concern you are facing with the form so we can suggest based on that.

    A URL to the page where you have the form would also be helpful. Looking forward to your response.

    Kind Regards,
    Nithin

    Thread Starter Mad Max

    (@mad_max)

    I got it!
    While I was trying to explain the problem better, I came up with the solution!

    The problem arises when you select the first radio option in {radio-2}, i.e the online payment with Paypal or Credit card. Only in that case, the {checkbox-1} element (that is checked by default) is hidden by this rule:

    SHOW IF {radio-2}
    IS NOT "ONLINE: Paypal..."

    and cascading, the fields that depend on its display state (name-3, name-4, text-8, text-9 etc.), are hidden with a rule like this:

    SHOW IF {checkbox-1} 
    IS NOT <checkbox-value>

    That’s because only when {checkbox-1} is visible and unchecked, I need to show theese fields.

    But I found that this combination of rules is ambiguous. What’s the value of an hidden checkbox, that is checked by default? And how other fields depending on it, behave when checking for its value?

    Adding the same {checkbox-1} visibility rule to all the other fields depending on its state, and so better specifying the visibility cases, fixes the problem.

    I don’t know if I managed to explain myself, so here you will find the fixed and working form in case you want to check the solution.

    Thank you so much for the time you spent on this for me! I really appreciate it.

    Daniele

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @mad_max

    But I found that this combination of rules is ambiguous. What’s the value of an hidden checkbox, that is checked by default? And how other fields depending on it, behave when checking for its value?

    The default value will be defined in the field itself https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#checkbox-field but if it is hidden there is not actually “selected” value as the scripts will validate it only when the field is visible.

    Thank you for sharing the form too and feel free to let us know if you have any additional questions on this.

    Best Regards
    Patrick Freitas

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hidden required fields prevent submitting form’ is closed to new replies.