• Resolved roehrer

    (@roehrer)


    The Form Elements I am using:

    [checkbox checkboxQs "group-none" "group-coh" "group-inline" "group-both"]
    [group group-none clear_on_hide][text text-693][/group]
    [group group-nested][text text-62][date date-476][/group]

    And the corresponding conditions:

    show [group-none] if [checkboxQs] equals "group-none"
    show [group-nested] if [text-693] equals "show"

    Code-snippet for Reference:

    if ($group.attr('data-clear_on_hide') !== undefined) {
      $(':input', $group)
        .not(':button, :submit, :reset, :hidden')
        .val('')
        .prop('checked', false)
        .prop('selected', false);
    
    }

    What I am essentially trying to do: when hiding the group-none group, hide the group-nested group as well. That should, as I understand it, be happening (almost*) on it’s own after the value of text-693 has been cleared using the group’s clear_on_hide attribute and the appropriate function. (*I would need to call the display_fields() function again after clearing the input fields (that function makes the fields dis- and appear)

    Using Google, the debug menu from Chrome and some editing in the script.js (which has been reversed now), I have been able to determine that when using the jQuery Selector, the “text-693″ input field is emptied by .val(”);. But using document.querySelector(“Selector for the text-693 input”), the value stays, even after being supposedly cleared by .val(”);. Also, when showing the group-none group again, the value of the text-693 input is still present.

    One maybe noteable thing: The form is not public on the website, it’s still a private page.

    After looking for some time, I have still not found what could be the problem here. I would be very greatful for assistance, as I have seemingly reached the ceiling of my expertise.

    Thank you!

    • This topic was modified 7 years, 9 months ago by roehrer. Reason: Made Code look like code

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

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

    (@jules-colle)

    I understand the problem. I’m working on a solution, but it’s a bit tricky, because calling the display_fields() function again inside display_fields() could cause endless loops (and will make the site crash) if people are not careful constructing their conditional fields.

    That being said, I’m working on a solution and will try and get back to you soon.

    Plugin Author Jules Colle

    (@jules-colle)

    Hey, I think I fixed it in the development version. You can see it in action here (Scroll down to the 2nd example):https://conditional-fields-cf7.bdwm.be/clear_on_hide/

    You can download the development version here: https://downloads.wp.xz.cn/plugin/cf7-conditional-fields.zip

    Note that if all you want is to nest your groups, you can simply nest them like this:

    [checkbox checkboxQs "group-none" "group-coh" "group-inline" "group-both"]
    [group group-none clear_on_hide]
      [text text-693]
      [group group-nested][text text-62][date date-476][/group]
    [/group]
    
    Thread Starter roehrer

    (@roehrer)

    Thanks!

    Actually nesting the groups and not only calling one of them nested is what I wanted appearently. Why ever I didn’t think of that myself…
    Thank you for making it work regardless!

    And thank you for the professional and friendly answer!

    Plugin Author Jules Colle

    (@jules-colle)

    You’re welcome! Feel free to leave a review if you like the plugin 🙂

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

The topic ‘clear_on_hide not working’ is closed to new replies.