Support Forum
Support › Meta Box Builder › Conditional Logic: show field if has value
Hello
I cannot figure out how to make the conditional logic (in the builder) to show the field, if it has a value.
In your documentation this example is missing or I can't see it.
I need this for a simple text field and for the advanced image.
Your documentation should als include some examples with the builder, not only for code.
Thanks in advance
François
Hello,
You can use the operator != (not equal) and leave an empty value to show a field if the target field has a value. Screenshot https://imgur.com/ax8gEH3
Hello
Thanks, I tried that already and it's not working. Right now almost nothing is working fine with Meta Box.
Just see this example
https://www.berrycast.com/conversations/a963bf4a-40c0-545e-9336-fbb41711fe7d
Hello,
You can not show a field based on its value, it's not how the conditional logic works. You can show/hide a field based on another field value. Please try this again with this case:
- create two fields with the following IDs: custom_text1
, custom_text2
- set custom_text1
visible if custom_text2
is not empty like this screenshot https://imgur.com/ax8gEH3
Read more in the documentation https://docs.metabox.io/extensions/meta-box-conditional-logic/
Hello
Thanks, I didn't know I can't use condition for the field it self. But never the less the conditions are still not working. See example https://www.berrycast.com/conversations/432ccc77-81f8-52b7-b1bf-a970a20b1d2b.
Please let me know what is wrong with this simple example from the video.
Thanks and regards
François
Hello,
I've created two fields like your screen record and did not see any issues. You can create a new field group with only two fields and deactivate all other plugins, leave only Meta Box, MB extensions plugins, switch to a standard theme of WordPress then check this again.
https://imgur.com/DVCdGSQ
Hello
Thank you for your video. I know it should work like that. But on my video you have seen it does not work, and this is a fresh and simple wp install with a default wp theme. I also tried your e-star theme which does not change anything.
I think you should be interested to check why this is not working and maybe finding a bug. Maybe this is then the same bug which causes the 'all fields lost' from my other ticket.
https://support.metabox.io/topic/all-fields-in-field-group-lost/?swcfpc=1
(you also have access to my install from this other ticket and I also sent you the corrensponding field group via email).
I'm also wondering why the ajax is not working (and why the inline checkboxes are styled so ugly with no space to the label). It does not make fun to use the builder like this right now.
Hello,
On your staging site, I do not see a field group that has the custom field "teaser" like that. Can you please create those custom fields or import field group to the staging site and let me check the issue?
Hello
I think I have found the reason.
It's because of the word 'auto'. Conditions with this word are not working properly.
That would explain, why I have so much trouble with these conditions, because I use 'auto' a lot.
See example here:
https://www.berrycast.com/conversations/631ac529-4ab1-55b8-bf86-a88732542062
Can you please recheck this?
Thanks, François
Hello,
I do not see that issue on your staging site https://temp1.goninski.ch/wp-admin/admin.php?page=goa#tab-options
with two fields Modus and Test Modus.
On your local site, you can try to add the field ID prefix to the conditional logic or remove the field ID prefix and recheck this issue. Screenshot https://imgur.com/w3lO9Co
If you create a screen record, please make it on the staging site so I can check the issue. Thanks.
Hello
It is really strange. Right now seems to work on the staging site. On my local installation I changed all values to 'autom' instead of 'auto' and since then there is no problem anymore.
...can't beliebe but it's true.
I'll come back when strange things are happening again, which I do not hope.
Thanks for your help
Regards, François