Support » Plugin: Contact Form 7 - Conditional Fields » WPML Conditional Fields not working on translations

  • Resolved jayhybrid

    (@jayhybrid)


    Hello,

    I am using Contact Form 7 (and Conditional Fields) with WPML and if I translate the contact form, the WPML way without creating a second form in another language but with the WPML Contact Form 7 Multilingual plugin/extension the conditional logic no longer works.

    Example:
    Original (DE): filling out the 3rd field from the top (Name) opens a drop drown.
    Translation (EN): /contact-us/ filling out the 3rd field from the top (Name) doesn’t do anything.

    My Developer console is showing me a JS Error which I think is related to this: TypeError: conditions.filter is not a function.

    Regards
    Jay

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    I believe this is also related to this bug: https://wordpress.org/support/topic/javascript-issue-14/

    Will try to fix it by the end of the week.

    Hi Jules

    I just updated to version 1.7.9 and also updated my Contact Form Translation and the issue seems to persist.

    Is there anything I can do to help you with this issue?

    Thanks
    Jay

    Plugin Author Jules Colle

    (@jules-colle)

    If you could set up a minimal wp installation to illustrate the malfunctioning of the plugin, that might help. So you can tell me the steps and I can reproduce it.

    jayhybrid

    (@jayhybrid)

    Alright, I have set up a fresh WP Installation here (http://debug.hybridsupply.de) and installed

    • Contact Form 7
    • Contact Form 7 Conditional Fields
    • Contact Form 7 Multilingual
    • WPML Multilingual CMS
    • WPML String Translation
    • WPML Translation Management

    There is a contact Form with a single field on the first page (which works, as it should): Entering something into the field, triggers some condition and a second field appears.

    Using WPML and Contact Form 7 Multilingual (WPML Extension) I have translated the Form, the WPML way and it can be seen in the German Version of the page, yet the conditional logic is not working.

    Plugin Author Jules Colle

    (@jules-colle)

    I tried to reproduce this but everything is working fine when I set up wpml.

    I do see that conditions are an empty string, while it should be an empty array. I have a feeling that your problem will be solved if you go to your German form in the backend, open the conditional fields tab, make sure the conditions are present, and click save. Could you give that a try?

    Plugin Author Jules Colle

    (@jules-colle)

    Or even better, could you quickly check if this works?

    Go to plugins/cf7-conditional-fields/cf7cf.php and change the function at line 345 to this:

        public static function getConditions($form_id) {
            $options = get_post_meta($form_id,'wpcf7cf_options',true);
            return is_array($options) ? $options : array();
        }

    Please let me know, if that works, and I will include the change in the next update.

    Unfortunately, I could not notice a change after replacing the code.

    I’m no developer, but it seemed to be a JS related issue to me, since I am getting the above mentioned error on page load of the translated (German) page.
    TypeError: conditions.filter is not a function scripts.js:678:44

    /cf7-conditional-fields/js/scripts.js?ver=1.7.9

    jayhybrid

    (@jayhybrid)

    I actually just updated Contact Form 7 Multilingual to 1.0.2 and checked the conditional Fields for the German version of my Contact Form and they are entirely missing.

    There is also no JS error anymore.

    Plugin Author Jules Colle

    (@jules-colle)

    A bit technical, but in case you want to know: You are right there was a JS error. But the error was caused because it reads a JSON string that is generated by PHP. The JSON string should contain an array for the conditions, but it did not. So, the JS error was actually caused by PHP not making sure it passes an array before generating the JSON string.

    So at this point, I think the problem is resolved. You just need to make sure to add your conditions to the German form separately.

    jayhybrid

    (@jayhybrid)

    Ah I see, translating a Form does not copy the conditions? Should this be a feature request rather than a bug report?

    Plugin Author Jules Colle

    (@jules-colle)

    You could ask WPML if they want to implement this. Nothing I can do about this for now. You can tell them they can contact me if there’s anything I can do on my part to make CF more compatible with WPML

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