Support Forum
Support › Meta Box Conditional Logic › Conditional logic relation
I have a visible
condition with a when
and or
relation.
But the logic still seems to be a when
and and
relation. Is this a know bug?
I am also using tabs and groups together with this extension
Dear Nicolas,
Sorry for the long silence. Can you please post your code so I can check?
Tan
The argument is this
array(
'name' => esc_html__( 'Price', $plugin_name ),
'id' => "{$prefix}price",
'desc' => esc_html__( 'Input price without currency', $plugin_name ),
'type' => 'text',
'clone' => false,
'size' => 25,
'tab' => 'dish',
// 'visible' => array( "{$prefix}menu_item_type", '!=', '0' ),
'hidden' => array(
'when' => array(
array( "{$prefix}menu_item_type", 'not in', array( 'item_type_a_la_carte', 'item_type_table_hote', 'item_type_combo' ) ),
array( "{$prefix}table_hote_price_radio", '=', 'no' ),
),
'relation' => 'or',
),
),
I tried the hidden logic but I have the same issue, it seems to be using an and
logic.
the {$prefix}table_hote_price_radio
radio button is visible when item_type_table_hote
is selected. The {$prefix}price
textbox is supposed to show on all selection but it will show only on item_type_table_hote
when {$prefix}table_hote_price_radio
is set to yes
Dear nicolas,
I've tested with my site and it works. This is my meta box:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes )
{
$meta_boxes[] = array(
'id' => 'brand_product',
'title' => 'Brands and Products',
'post_types' => array( 'post', 'page' ),
'context' => 'normal',
'priority' => 'high',
// Conditional Logic can be applied to Meta Box
// In this example: Show this Meta Box by default. Hide it when post format is aside
'hidden' => array( 'post_format', 'aside' ),
'fields' => array(
array(
'id' => 'brand',
'name' => 'Brand',
'desc' => 'Pick Your Favourite Brand',
'type' => 'select',
'options' => array(
'Apple' => 'Apple',
'Google' => 'Google',
'Microsoft' => 'Microsoft'
)
),
array(
'id' => 'apple_products',
'name' => 'Which Apple product that you love?',
'type' => 'radio',
'options' => array(
'iPhone' => 'iPhone',
'iPad' => 'iPad',
'Macbook' => 'Macbook',
'iWatch' => 'iWatch'
),
// Conditional Logic can applied to fields
// In this example: Show this field by default,
// hide it when user selected different value than 'Apple' on brand select field
'hidden' => array( 'brand', '!=', 'Apple' )
),
array(
'name' => 'Price',
'id' => "tan_price",
'desc' => 'Input price without currency',
'type' => 'text',
'clone' => false,
'size' => 25,
'tab' => 'dish',
// 'visible' => array( "{$prefix}menu_item_type", '!=', '0' ),
'hidden' => array(
'when' => array(
array( "brand", 'not in', array( 'Google', 'Microsoft' ) ),
array( "post_category", 1 ),
),
'relation' => 'or'
),
),
)
);
return $meta_boxes;
} );
It hidden when either brand
is Apple or post_category
is 1.
If this problem still persist, can you please send me your website credentials and FTP info via contact form so I can login your website to check?
Best regards,
Tan