• Resolved costelcar

    (@costelcar)


    I have an issue with “hide” logic groups. My form code is:

    [checkbox checkbox-814 id:flexible default:1 “Totally Flexible”]
    [group group-flex]
    [text ...]
    [/group]

    [checkbox* checkbox-howdid id:web free_text “Information / Outreach meeting” “Word of Mouth” “Internet” “Other”]
    [group group-web]
    [text ...]
    [/group]

    and my conditions are:
    if [checkbox-howdid] equals “Internet” then show [group-web]
    if [checkbox-814] equals “Totally Flexible” then show [group-flex]

    The second field/group works as expected, when “Internet” is checked the form appears, but the first one doesn’t. The first one doesn’t do anything, although it should be hidden by default (since the checkbox is initially checked), and if unchecked, the group should show.

    Am I doing some mistakes in understanding the logic or implementing?

Viewing 12 replies - 1 through 12 (of 12 total)
  • no it must be a bug i have the same problem but your report contains an error.

    The first one doesn’t do anything, although it should be hidden by default (since the checkbox is initially checked), and if unchecked, the group should show.

    if [checkbox-howdid] equals “Internet” then show [group-web]

    should be:
    if [checkbox-814] equals “Totally Flexible” then hide[group-flex]

    it won’t work even if you change that. i am sure its a but. i just wanted to report exactly that.

    • This reply was modified 9 years, 7 months ago by cesare2016.
    • This reply was modified 9 years, 7 months ago by cesare2016.
    • This reply was modified 9 years, 7 months ago by cesare2016.
    • This reply was modified 9 years, 7 months ago by cesare2016.

    sorry.
    if [checkbox-814] equals “Totally Flexible” then show[group-flex]

    should be:
    if [checkbox-814] equals “Totally Flexible” then hide[group-flex]

    Thread Starter costelcar

    (@costelcar)

    Hi Cesare, thanks for confirming there is a bug. Although I don’t think there was a mistake in my report. When I said “the first one” I was referring to the first one that appears in the form, in the code, thus the checkbox-814 which is as I described, checked by default, and it should hide the group when unchecked. The conditions were in the reverse order written, since I tried every idea, including changing the order of the conditions, but that didn’t help.

    So the full code to reproduce the bug is:

    FORM

    When are you available for work? [checkbox checkbox-814 id:flexible default:1 "Totally Flexible"] OR:
    [group group-flex]
    [text your-availability  id:not_flexible placeholder "e.g. Monday morning, Wednesday evening, Friday afternoon, Saturday and Sunday"]
    [/group]
    How did you find out about our services?
    [checkbox* checkbox-howdid id:web "Friends" "School" "Internet"]
    [group group-web]
    The name of the website where you found about us:
    [text your-website id:show_web placeholder "e.g. www.google.com"]
    [/group]
    

    CONDITIONS

    if [checkbox-814] equals "Totally Flexible" then hide [group-flex]
    if [checkbox-howdid] equals "Internet" then show [group-web]
    

    I didn’t have time to wait for the developer so I fixed it myself, had to deliver the project. The plugin code is pretty ok written, but there is a clear bug when showing fields, it actually does not take at all into consideration the “hide” action. My fix is pretty simple, I just changed the “.show()” actions into “.toggle()” – I haven’t tested all condition combinations and input types, but it worked for my project. So the changes I did were:

    /wp-content/plugins/cf7-conditional-fields/js/scripts.js

    change all appearances (lines 63, 72, 90, 92) of
    $('#' + unit_tag + ' #' + condition.then_field).show();
    into
    $('#' + unit_tag + ' #' + condition.then_field).toggle();

    Maybe the developer will read this someday and hopefully implement in a next version, it would be a pity not to, for such a useful little plugin.

    • This reply was modified 9 years, 7 months ago by costelcar.
    • This reply was modified 9 years, 7 months ago by costelcar.

    Hi Costelcar
    Now I see. Thanks a lot for your fix. I also can’t wait for a new release actually… I will let know Jules about your fix.

    By the way: Do you know how to reset controls after the have been toggled. I mean if somebody checks something and the hides this part of the form I’d like to reset the checked control.

    Thanks.

    Thread Starter costelcar

    (@costelcar)

    Can you give me a bit more details? I’m not sure what you mean by “resetting” the checked control.

    sure. thanks for your help. basically it means uncheck checked checkboxes.

    if somebody makes a part of the form “disappear” and “appear” again i want to reset all the controls (i.e. uncheck checked checkboxes) in there. How to do that? (Now e.g. checked boxes stay checked.)

    Thread Starter costelcar

    (@costelcar)

    If you’re just asking the javascript detail, how to check/uncheck an input type=checkbox, then you can do:
    $(‘#checkboxId’).prop(‘checked’, true);
    or
    $(‘#checkboxId’).prop(‘checked’, false);

    of course you need to consider the default state when resetting, for instance in my case the default option for that checkbox was checked.

    no chance to get it working for my case. whatever i change and do…i need it working for the end of the year at latest…

    thanks for the checkbox hints

    i need somebody to fix it for me. if you like you cold do it for me. i am going to pay you for that.

    Thread Starter costelcar

    (@costelcar)

    Give me your email address please.

    Moderator James Huff

    (@macmanx)

    If you need to hire someone, please try http://jobs.wordpress.net/ or https://jetpack.pro/ and do not accept any hire or direct access offers posted to these forums.

    We ask that you please observe https://codex.wordpress.org/Forum_Welcome#Offering_to_Pay and not solicit work on these forums.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Side note: @costelcar and @cesare2016 Please do not ask for or post emails in these forums again.

    https://codex.wordpress.org/Forum_Welcome#The_Bad_Stuff

    That is something that is explicitly discouraged here.

    i need somebody to fix it for me. if you like you cold do it for me. i am going to pay you for that.

    As this has moved into “Offering to pay” I am now closing this topic.

    • This reply was modified 9 years, 7 months ago by Jan Dembowski.
Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Single checkbox hide rule not working’ is closed to new replies.