MB Conditional Logic is not working in Customizer
Support › MB Settings Page › MB Conditional Logic is not working in Customizer
- This topic has 9 replies, 6 voices, and was last updated 2 years, 3 months ago by
Peter.
-
AuthorPosts
-
November 22, 2021 at 8:29 PM #32102
Razib
ParticipantConditional Logic is not working on Customize
https://pastebin.com/embed_iframe/4rpW8buS?theme=darkNovember 23, 2021 at 12:52 PM #32113Long Nguyen
ModeratorHi,
The conditional logic works as well on my site, screen record https://share.getcloudapp.com/xQujoZyN
You can try to deactivate all plugins except Meta Box, MB extensions and switch to the standard theme of WordPress to re-check this issue.
February 5, 2022 at 9:00 PM #33660Gunther Pilz
ParticipantHi,
I am having the same problem. The Conditional Logic is not working in Customizer.
It works fine on the Settings Page but not if you use it in the Customizer.So there has to be definitely a bug - please check and correct.
February 7, 2022 at 8:31 PM #33713Long Nguyen
ModeratorHi Gunther,
Can you please share the code that creates the fields and conditional logic on your site? As you can see on the screen record above, it works as well on my demo site.
https://imgur.com/G4lFxi1October 26, 2022 at 11:50 PM #38836Ioannis Tsimpidis
ParticipantIs this also true for when using conditional logic for fields inside a cloneable group in customizer?
Currently this isn't working for me. Can you confirm?October 27, 2022 at 12:50 PM #38846Long Nguyen
ModeratorHi Ioannis,
Can you please share the code that creates the custom fields and conditional logic on your site? I will help you to check the issue.
You can also follow this documentation to know how to use conditional logic with subfields in a group https://docs.metabox.io/extensions/meta-box-conditional-logic/#using-with-group
January 19, 2023 at 4:59 AM #40257Luca
ParticipantHi,
I am having the same problem.The Conditional Logic is working in the Settings page, but it is not working in the Customizer.
Please, see the video:
https://share.getcloudapp.com/P8uNX1LkWith a clean WordPress installation (6.1.1),
Meta Box 5.6.15,
Meta Box AIO 1.17.0No other plugins
No other Custom Fields
No other Settings Pages
All available extensions activated
No console errorsCustom Fields created with MB Builder:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Test 1', 'your-text-domain' ), 'id' => 'test-1', 'settings_pages' => ['test'], 'fields' => [ [ 'name' => __( 'Select', 'your-text-domain' ), 'id' => $prefix . 'select_test_1', 'type' => 'select', 'options' => [__( 'Hide{/translate}', '{translate}Show', 'your-text-domain' )], ], [ 'name' => __( 'Text', 'your-text-domain' ), 'id' => $prefix . 'text_nhbsf837xqg', 'type' => 'text', 'visible' => [ 'when' => [['select_test_1', '=', 1]], 'relation' => 'or', ], ], ], ]; return $meta_boxes; }
Thanks in advance
January 19, 2023 at 11:41 PM #40264Peter
ModeratorHello Luca,
The options of the select field look incorrect when setting up. Please change it to this one and let me know if it works.
'fields' => [ [ 'name' => __( 'Select', 'your-text-domain' ), 'id' => $prefix . 'select_test_1', 'type' => 'select', 'options' => [ 'a' => __( 'A', 'your-text-domain' ), 'b' => __( 'B', 'your-text-domain' ), 'c' => __( 'C', 'your-text-domain' ), ], ], [ 'name' => __( 'Text', 'your-text-domain' ), 'id' => $prefix . 'text_nhbsf837xqg', 'type' => 'text', 'visible' => [ 'when' => [['select_test_1', '=', 'b']], 'relation' => 'or', ], ], ]
January 20, 2023 at 6:56 AM #40267Luca
ParticipantHi Peter,
thanks for answer me.The code reported in my previous post was provided from the "Get PHP Code" of the Builder (Choices= 0:Hide
1:Show) and I agree it looks a bit messyI have tried with your modifications and still obtains same results (working nicely in settings page and not working in Customizer):
https://share.getcloudapp.com/QwujBKkG
I also noticed that by trying the Customizer repeatedly, sometimes it works correctly. But I have not found a consistent behavior.
I have used the following:
Clean WordPress installation (6.1.1),
Meta Box 5.6.15,
Meta Box AIO 1.17.0Theme: Twenty Twenty-Two
No other plugins
No Custom Fields via Builder
No Settings Pages via Builder
All MB available extensions activated
No console errorsSettings Page and Custom Fields created with the following code in functions.php:
add_filter( 'mb_settings_pages', 'lm_settings_page' ); function lm_settings_page( $settings_pages ) { $settings_pages[] = [ 'menu_title' => __( 'LM: Test', 'your-text-domain' ), 'id' => 'lm-settings-test', 'position' => 25, 'style' => 'boxes', 'columns' => 1, 'customizer' => true, 'icon_url' => 'dashicons-admin-generic', ]; return $settings_pages; } add_filter( 'rwmb_meta_boxes', 'lm_meta_boxes' ); function lm_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'LM: Test 1', 'your-text-domain' ), 'id' => 'test-2', 'settings_pages' => ['lm-settings-test'], 'fields' => [ [ 'name' => __( 'Select', 'your-text-domain' ), 'id' => $prefix . 'select_test_1', 'type' => 'select', 'options' => [ 'a' => __( 'A', 'your-text-domain' ), 'b' => __( 'B', 'your-text-domain' ), 'c' => __( 'C', 'your-text-domain' ), ], ], [ 'name' => __( 'Text', 'your-text-domain' ), 'id' => $prefix . 'text_nhbsf837xqg', 'type' => 'text', 'visible' => [ 'when' => [['select_test_1', '=', 'b']], 'relation' => 'or', ], ], ] ]; return $meta_boxes; }
I am glad to help investigate this problem.
Please, let me know.January 20, 2023 at 10:31 PM #40272Peter
ModeratorHello,
I don't see that issue on my end, here is the screen record https://monosnap.com/file/M2QPFXucFX9PAVkRRg87QvVcIqeB9Y
If the conditional logic still does not work in the customizer on your site, please share your site credentials to the contact form https://metabox.io/contact/
I will help you to check the issue. -
AuthorPosts
- You must be logged in to reply to this topic.