• Hello,

    when I installed the 4.9 version the form stopped working. It was giving validation errors.
    I am Using CF7 Skins logic, which hides some radio boxes if they should not be displayed.

    The problem is related to the new feature in the changelog “Shows a validation error when no option in a radio buttons group is checked”.

    This is making CF7 to check the radio boxes not displayed and validates them. They shouldn’t be validated if not displayed.

    So as a temporary workaround I downgraded. Now the request form is working.
    You can see the form here and test the radio boxes if you wish.

    I think there should be the option to disable validation for radio boxes.

    Can you please help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • eaglejohn

    (@danielbenjamins)

    Same problem here. Although the changelog says it should be fixed, this bug is still present in version 4.9.1. I also downgraded to version 4.8.1 and it’s working again.

    Thread Starter utnalove

    (@utnalove)

    I hope the authors will not keep ignoring this thread.
    It shouldn’t be hard to add an option to make the radio boxes mandatory or not.

    eaglejohn

    (@danielbenjamins)

    There’s barely support for this plugin. I already switched to Gravity Forms a long time ago, but some of my older sites are still using CF7…

    As I had the same issue I looked at the code and it seems as this is easy to fix. It boils down to removing the validation for the “radio” field like this:

    
    remove_filter( 'wpcf7_validate_radio', 'wpcf7_checkbox_validation_filter', 10 );
    

    Be aware that this globally disables validation for “radio”. I don’t see any side-effects right now but be aware what you are doing here.

    For anyone wanting to dig deeper, this is the relevant change in 4.9: https://plugins.trac.wordpress.org/browser/contact-form-7/tags/4.9/modules/checkbox.php#L206

    Thomas —

    Thank you for the code that might solve this problem. Could you tell us specifically where to add the code?

    Edit: Never mind — I just dropped it into my “functions” file & (so far) everything works fine — no more validation error.

    Thanks!

    • This reply was modified 6 years, 3 months ago by Jim Reading.

    Here is another solution if you still require some radio buttons to be required:

    Add a required class to your radio fields that still need to be required:

    [radio theName class:required "Yes" "No"]

    Then add this code to functions.php

    remove_filter('wpcf7_validate_radio', 'wpcf7_checkbox_validation_filter', 10);
    
    add_filter('wpcf7_validate_radio', function($result, $tag) {
      if (in_array('class:required', $tag->options)) {
        $result = wpcf7_checkbox_validation_filter($result, $tag);
      }
      return $result;
    }, 10, 2);
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to disable or fix the new feature of radio buttons?’ is closed to new replies.