Conditional logic may not be working
Support › MB Conditional Logic › Conditional logic may not be workingResolved
- This topic has 2 replies, 2 voices, and was last updated 2 years, 4 months ago by
seaj1one.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
December 24, 2022 at 10:50 PM #40021
seaj1one
ParticipantI've copied the below from get PHP code I've updated it to the latest release.
If I select one checkbox_list it shows but if I select both it doesn't.
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'services section', 'your-text-domain' ), 'id' => 'services-section', 'post_types' => ['page', 'service-areas', 'service'], 'fields' => [ [ 'name' => __( 'Service hero', 'your-text-domain' ), 'id' => $prefix . 'service_hero', 'type' => 'group', 'fields' => [ [ 'name' => __( 'title', 'your-text-domain' ), 'id' => $prefix . 'title', 'type' => 'text', ], [ 'name' => __( 'text', 'your-text-domain' ), 'id' => $prefix . 'text', 'type' => 'text', ], [ 'name' => __( 'image', 'your-text-domain' ), 'id' => $prefix . 'image', 'type' => 'single_image', ], [ 'name' => __( 'additional_services_groups', 'your-text-domain' ), 'id' => $prefix . 'additional_services_groups', 'type' => 'checkbox_list', 'options' => [ 'none' => __( 'none', 'your-text-domain' ), 'services_offered_card' => __( 'services_offered_card', 'your-text-domain' ), 'service_offered_group_of_images1' => __( 'service_offered_group_of_images1', 'your-text-domain' ), ], ], ], ], [ 'name' => __( 'services offered card', 'your-text-domain' ), 'id' => $prefix . 'services_offered_card', 'type' => 'group', 'collapsible' => true, 'clone' => true, 'sort_clone' => true, 'fields' => [ [ 'name' => __( 'title', 'your-text-domain' ), 'id' => $prefix . 'title', 'type' => 'text', ], [ 'name' => __( 'text', 'your-text-domain' ), 'id' => $prefix . 'text', 'type' => 'text', ], [ 'name' => __( 'image', 'your-text-domain' ), 'id' => $prefix . 'image', 'type' => 'single_image', ], ], 'hidden' => [ 'when' => [['additional_services_groups', '!=', 'services_offered_card']], 'relation' => 'or', ], ], [ 'name' => __( 'service_offered_group_of_images1', 'your-text-domain' ), 'id' => $prefix . 'service_offered_group_of_images1', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => [ [ 'name' => __( 'images', 'your-text-domain' ), 'id' => $prefix . 'images', 'type' => 'single_image', 'clone' => true, 'sort_clone' => true, ], ], 'hidden' => [ 'when' => [ [ 'additional_services_groups', '!=', 'service_offered_group_of_images1', ], ], 'relation' => 'or', ], ], ], ]; return $meta_boxes; }
December 25, 2022 at 11:06 PM #40027Peter
ModeratorHello,
If you use the field checkbox_list, please use the operator
in
to check the conditional logic. Please read more on the documentation https://docs.metabox.io/extensions/meta-box-conditional-logic/#syntaxIf you use the builder, please see this screenshot https://monosnap.com/file/5jHctYShpEhn4AKMaFJ3cFZu87AWRd
December 27, 2022 at 11:22 PM #40042seaj1one
ParticipantHello Peter
I was able to make it work using your suggestion.
I'm happy for this ticket to show as being resolved.
Kind regards
Stephen
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.