• Upgrade to 6.0 introduces a validation error thrown for radio buttons with (intended) whitespace surrounding specific radio items.

    From what I can see is that within Schema Woven Valdiation rule ‘enum’ (contact-form-7/includes/swv/php/rules/enum.php), the incoming $input still has the whitespace (in my case, a “  ” at the beginning), which is then removed by
    wpcf7_strip_whitespaces( $input );
    in line 24.
    However, $acceptable_values has the whitespace (which I think is correct and preferred, as it’s a radio value defined by intent).

    Therefore the following loop to check for accepted values fails and throws the corresponding ‘unknown value’ validation error.
    In order to not break existing forms and validations (causing a lot of work in later stages of form data use) , I suggest to
    (a) either omit to strip whitespace (which may interfere with https://contactform7.com/2024/07/13/consistent-handling-policy-of-surrounding-whitespaces/ )
    or
    (b) have a temporary wpcf7_strip_whitespaces( ... ) also on accepted values, so that anything that fits stripped values on both sides is accepted without validation error.

    Thank you for considering this suggestion.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter MartinW2

    (@martinw2)

    It seems the return value is stripped in any case – no matter if validation is on/off, or option (a) or (b) is chosen to resolve the error.
    Anyway, even if there is a forced trim on the result value (which I don’t like for checkboxes, radio and selects, as it is intended by the form creator and not filled in by the user), please resolve this validation error by either (a) or (b).

    Thread Starter MartinW2

    (@martinw2)

    Sh*t. Even if class ‘novalidate’ is added to the affected radio field, it only helps initially to supress the ajax validation error. That’s why I thought it is sufficient to solve via changes mentioned above. BUT any follow up validation of OTHER checkboxes etc. will bring up the error again.
    Oh my, please stop this excessive checking or make it tolerant against trimmed vs non-trimmed version!
    I will have to completely roll back or suppress ANY form validation (if this is possible).

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter MartinW2

    (@martinw2)

    It’s a non-profit organisation website, which can only be reached from within Germany (please use VPN or let me know your country so I can temporarily open it up).
    Here is a link to a small test form: https://tv-schlierbach.de/wp/test-form/
    The critical point is to have a radio button or checkbox e.g. like this:

    [radio beitrag id:beitrag use_label_element default:1 
    "120 € : no blanks - Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
    "100 € : no blanks - commodo ligula eget dolor. Aenean massa. Cum sociis natoque."
    "  80 € : leading nbsp - penatibus et magnis dis parturient montes, nascetur."
    "  60 € : leading nbsp - Donec quam felis, ultricies nec, pellentesque eu."
    ]

    Validation does not allow to select the last two options.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Remove   from the values.

    Thread Starter MartinW2

    (@martinw2)

    Well, the   is of course intended – that’s the point, as I mentioned right on top.
    It worked before – and the update is breaking the form.
    I already depicted a possible solution which will still allow all kinds of whitespace around the value (see b), it just needs to be extended by a corresponding relaxed check for ajax-validation.
    This problem in general might affect others as well. If values are trimmed for all whitespace, validations should run on the same trim methods at least. Which is currently not the case. Hence the validation error on radio button, checkbox or select value.
    Please consider a coding improvement that will not break old forms.
    For Checkbox, Radio, Select, I would even recommend to skip trimming whitespace, as theses values are provided by content developers who usually know what/why they are using whitespace.
    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.