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.