Skip Navigation

[Resolved] Adding conditional to checkbox field causes js to display none on post admin scr

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1248789
Screen Shot 2019-05-23 at 8.56.10 PM.png
Screen Shot 2019-05-23 at 8.52.39 PM.png
Screen Shot 2019-05-23 at 8.52.48 PM.png

I have added a simple conditional to a custom field. It works as expected, however, the checkbox is now hidden on the post admin screen.

The field is a checkbox which is part of a field group.

Debug shows 'js-wpt-field wpt-field js-wpt-checkbox wpt-checkbox wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' with style for checbox data-wpt-id set to 'style="display: none;'

Value to show in the selected field is '<div class="badge-width item-badge"><span class="title-c">Editor's Choice</span>'

My conditional statement is '$(editor-s-choice) eq ‘item - badge’

#1248847

Hello,

I have tried it in my localhost, there isn't the similar problem as you mentioned above:
the checkbox is now hidden on the post admin screen.

And since your custom checkbox field "editor-s-choice" stores numeric value "1", the "Data-dependent display filters" should use the value 1 too, for example:

($(editor-s-choice) eq 1) 
#1248851

You fixed it and I LOVE YOU! Thanks, Luo!

#1248853

I spoke too soon. The field was showing in post admin, not it is not showing randomly.

#1248855

🙁 I still love you, tho! (Pls help.)

#1248857

Since there isn't the same problem in my localhost, please check these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, deactivate all custom PHP/JS code snippets, and test again

2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1248911

Pret-ty sure it's fixed. I replaced

 $(editor - s - choice) eq 1) 

with

 jQuery(editor - s - choice) eq 1)

and everything seems to be working. THANK YOU!

#1248967

Thanks for sharing the solution.

In my localhost, it does not need to use jQuery, please let me know if you need more assistance for it.