• Resolved Todd Edelman

    (@toddedelman)


    Hi there

    Please see [ redundant link removed ]. The ‘Apply Now’ button should open a Contact Form 7 form in which we’re using your plugin in. Here’s the code we’ve used in the form:

    <p> Full Name*
        [text* full-name] </p>
    
    <p> Email Address*
        [email* email-address] </p>
    
    <p class="auto-fill-country-code" data-for=".phone-number"> Country*
        [select* menu-country include_blank]</p>
    
    <p class="phone-number"> Phone Number
        [tel tel-368] </p>
    
    <p>What are you submitting?*
        [radio radio-635 default:1 "CV" "LinkedIn Page URL"]</p>
    
    [group group-511-cv]
    <p>CV*
        [file file-468 filetypes:doc|docx|pdf]</p>
    [/group]
    
    [group group-693-linkedin]
    <p>LinkedIn Page URL*
        [url url-684]</p>
    [/group]
    
    <p> Add your own words
        [textarea message] </p>
    
    [submit "Send"]

    The idea is based on which radio button the select for “What are you submitting?” they’ll get one of two fields, either a file upload or URL.

    Here’s the issues:

    • When I make the radio button for “What are you submitting?” required the “radio-635” option doesn’t show in the list for “Select field” in your tab
    • Regardless of the above, selecting one of the radio buttons isn’t opening the next field

    Appreciate your help with this,
    Todd

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

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

    (@jules-colle)

    Note that there is no required version of radio (“radio*”). The reason Contact Form 7 doesn’t provide “radio*” is because a radio button is a required field by nature. The HTML spec document explains it more in detail.

    – source: https://contactform7.com/checkboxes-radio-buttons-and-menus/

    Second problem: Is seems like there are 6 forms in total being loaded on the page. One of them does not contain conditional fields, so a javascript error is triggered. This is probably something I should fix with the next update. I’ll check. You could likely fix it for now by making sure all your cf7 forms include at least one conditional rule (it can be something that does absolutely nothing if you like)

    Thread Starter Todd Edelman

    (@toddedelman)

    Thanks @jules-colle.

    I understand the comments about a required radio button.

    In regards to the second problem, do you know when you’ll get this fixed? I’ve reduced the number of forms that appear on job posts to three, and on the additional two, I added an empty conditional rule (such as [group group-196][/group]), but I’m still experiencing issues.

    Any more guidance and support would be appreciated.

    Thanks,
    Todd

    Thread Starter Todd Edelman

    (@toddedelman)

    @jules-colle and others experiencing this problem…

    We fixed the problem… Here’s the code to update in /wp-content/plugins/cf7-conditional-fields/js/scripts.js:

        // Old code
        /*$('.wpcf7').each(function(){
            $this = $(this);
            form_options = JSON.parse($this.find('input[name="_wpcf7cf_options"]').eq(0).val());
            form_options.unit_tag = $this.attr('id');
            options.push(form_options);
        });*/
    
        // Fixed code
        $('.wpcf7').each(function(){
            var $this = $(this);
            var options_element = $this.find('input[name="_wpcf7cf_options"]').eq(0);
            if (options_element.length) {
                var value = options_element.val();
                if (value) {
                    form_options = JSON.parse(value);
                    form_options.unit_tag = $this.attr('id');
                    options.push(form_options);
                }
            }
        });
    Plugin Author Jules Colle

    (@jules-colle)

    That was the fix it needed, indeed. Thanks for sharing!

    Hi both,

    Thanks for posting your solution to this @toddedelman!

    @jules-colle – have you considered putting this plugin on GitHub? I’m just thinking that this is a good example of making the most the WP community who are often willing to contribute with solutions and improvements. In that way, the plugin would quickly get even stronger and better and everyone would benefit from that 🙂 Just a thought…

    • This reply was modified 7 years, 11 months ago by skafte.
    Plugin Author Jules Colle

    (@jules-colle)

    Hi @jules-colle,

    Thanks for your response and for sharing the link to the GitHub repo!

    Apologies for not having found it myself. I wonder if it would be a good idea to add a link to it in the description of the plugin…?

    Anyway, thanks again! 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Conditional fields not opening using radio buttons’ is closed to new replies.