Conditional Logic: show field if has value
Support › MB Builder › Conditional Logic: show field if has value
- This topic has 10 replies, 2 voices, and was last updated 1 year, 9 months ago by
[email protected].
-
AuthorPosts
-
July 3, 2023 at 6:38 PM #42452
[email protected]
ParticipantHello
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çoisJuly 4, 2023 at 9:35 PM #42465Peter
ModeratorHello,
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
July 5, 2023 at 2:14 AM #42476[email protected]
ParticipantHello
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
July 5, 2023 at 9:50 PM #42488Peter
ModeratorHello,
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
- setcustom_text1
visible ifcustom_text2
is not empty like this screenshot https://imgur.com/ax8gEH3Read more in the documentation https://docs.metabox.io/extensions/meta-box-conditional-logic/
July 6, 2023 at 1:34 AM #42495[email protected]
ParticipantHello
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çoisJuly 6, 2023 at 10:19 PM #42504Peter
ModeratorHello,
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/DVCdGSQJuly 7, 2023 at 12:24 PM #42514[email protected]
ParticipantHello
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.
July 9, 2023 at 3:25 PM #42526Peter
ModeratorHello,
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?
July 10, 2023 at 11:25 PM #42534[email protected]
ParticipantHello
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-a88732542062Can you please recheck this?
Thanks, François
July 11, 2023 at 11:05 PM #42537Peter
ModeratorHello,
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.
July 18, 2023 at 4:30 AM #42613[email protected]
ParticipantHello
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 -
AuthorPosts
- You must be logged in to reply to this topic.