Support Forum
Support › MB Settings Page › Settings Page - Radio Buttons and Conditional Logic
We have a problem with our Metabox Settings Page.
In our settings page we can choose between 4 different layout types.
Depending on which layout you choose, there are appearing some other fields.
On each "Box" you can then choose between "Page", "Post" or "Link".
And depending on this selection there are appearing again some other fields.
Now the problem:
We start with no saved data. First create a new Layout with the option "2/3 - 1/3".
At the other fields, select anything, it doesn't matter.
After this we create another new layout through the button "Add more".
Then we choose the layout option "1/3 - 1/3 - 1/3".
Select the fields which appeared. When you select a option at "3. Box" no other fields are appearing. But there should also be some fields.
When you clear all the data, and choose as first layout "1/3 - 1/3 - 1/3", everything is working fine.
Can somebody please tell me what we make wrong?
Here is the code:
function webx_register_page_home($meta_boxes) {
$prefix = 'webx-';
$meta_boxes[] = array(
'id' => 'homero3',
'title' => __('Home-page settings', 'webx'),
'settings_pages' => 'homero3',
'fields' => array(
array(
'id' => 'standard',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'fields' => array(
array(
'id' => "{$prefix}layout",
'name' => __('Layout', 'webx'),
'type' => 'radio',
'inline' => false,
'options' => array(
'layout1' => '2/3 - 1/3',
'layout2' => '1/3 - 1/3 - 1/3',
'layout3' => '1/3 - 2/3',
'layout4' => '1/2 - 1/2',
),
'std' => 'layout1',
),
array(
"name" => __('1. Box', 'webx'),
'type' => 'heading',
'id' => 'header1'
),
array(
"name" => __('Page/Post/Link 1', 'webx'),
'id' => "{$prefix}choose-1",
'type' => 'radio',
'options' => array(
'selectPage' => __('Page', 'webx'),
'selectPost' => __('Post', 'webx'),
'selectLink' => __('Link', 'webx'),
),
),
array(
"name" => __('Select page', 'webx'),
'id' => "{$prefix}page-1",
'type' => 'post',
'post_type' => 'page',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-1", 'selectPage'
)
),
),
array(
"name" => __('Select post', 'webx'),
'id' => "{$prefix}post-1",
'type' => 'post',
'post_type' => 'post',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-1", 'selectPost'
)
),
),
array(
"name" => __('Link', 'webx'),
'id' => "{$prefix}link1",
'type' => "url",
'desc' => "Full url: http://www.google.com/ <br>opens in new tab",
'visible' => array(
array("{$prefix}choose-1", 'selectLink')
),
),
array(
"name" => __('Title', 'webx'),
'id' => "{$prefix}title-1",
'type' => "textarea",
'cols' => 4,
'rows' => 4,
'resize' => false,
'visible' => array(
array("{$prefix}choose-1", 'selectLink')
),
),
array(
"name" => __('Image', 'webx'),
'id' => "{$prefix}image-1",
'type' => 'image_advanced',
'max_file_uploads' => 1,
'visible' => array(
array("{$prefix}choose-1", 'selectLink')
),
),
array(
"name" => __('2. Box', 'webx'),
'type' => 'heading',
'id' => 'header2'
),
array(
"name" => __('Page/Post/Link', 'webx'),
'id' => "{$prefix}choose-2",
'type' => 'radio',
'options' => array(
'selectPage' => __('Page', 'webx'),
'selectPost' => __('Post', 'webx'),
'selectLink' => __('Link', 'webx'),
),
),
array(
"name" => __('Select page', 'webx'),
'id' => "{$prefix}page-2",
'type' => 'post',
'post_type' => 'page',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-2", 'selectPage'
)
),
),
array(
"name" => __('Select post', 'webx'),
'id' => "{$prefix}post-2",
'type' => 'post',
'post_type' => 'post',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-2", 'selectPost'
)
),
),
array(
"name" => __('Link', 'webx'),
'id' => "{$prefix}link2",
'type' => "url",
'desc' => "Full url: http://www.google.com/ <br>opens in new tab",
'visible' => array(
array("{$prefix}choose-2", 'selectLink')
),
),
array(
"name" => __('Title', 'webx'),
'id' => "{$prefix}title-2",
'type' => "textarea",
'cols' => 4,
'rows' => 4,
'resize' => false,
'visible' => array(
array("{$prefix}choose-2", 'selectLink')
),
),
array(
"name" => __('Image', 'webx'),
'id' => "{$prefix}image-2",
'type' => 'image_advanced',
'max_file_uploads' => 1,
'visible' => array(
array("{$prefix}choose-2", 'selectLink')
),
),
array(
"name" => __('3. Box', 'webx'),
'type' => 'heading',
'id' => 'header3',
'visible' => array(
array("{$prefix}layout", 'layout2')
),
),
array(
"name" => __('Page/Post/Link', 'webx'),
'id' => "{$prefix}choose-3",
'type' => 'radio',
'options' => array(
'selectPage' => __('Page', 'webx'),
'selectPost' => __('Post', 'webx'),
'selectLink' => __('Link', 'webx'),
),
'visible' => array(
array("{$prefix}layout", 'layout2')
),
),
array(
"name" => __('Select page', 'webx'),
'id' => "{$prefix}page-3",
'type' => 'post',
'post_type' => 'page',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-3", 'selectPage'
)
),
),
array(
"name" => __('Select post', 'webx'),
'id' => "{$prefix}post-3",
'type' => 'post',
'post_type' => 'post',
'field_type' => 'select_advanced',
'visible' => array(
array(
"{$prefix}choose-3", 'selectPost'
)
),
),
array(
"name" => __('Link', 'webx'),
'id' => "{$prefix}link3",
'type' => "url",
'desc' => "Full url: http://www.google.com/ <br>opens in new tab",
'visible' => array(
array("{$prefix}choose-3", 'selectLink')
),
),
array(
"name" => __('Title', 'webx'),
'id' => "{$prefix}title-3",
'type' => "textarea",
'cols' => 4,
'rows' => 4,
'resize' => false,
'visible' => array(
array("{$prefix}choose-3", 'selectLink')
),
),
array(
"name" => __('Image', 'webx'),
'id' => "{$prefix}image-3",
'type' => 'image_advanced',
'max_file_uploads' => 1,
'visible' => array(
array("{$prefix}choose-3", 'selectLink')
),
),
)
)
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'webx_register_page_home' );
Let me check and answer in the next 2 days 🙂
Dear web-crossing,
Sorry for the delay. I've check and see this is a bug of Meta Box Conditional Logic. I'm working with it and will release the patch within 48 hours.
Thanks and best regards,
I've released new version which fixed this bug. Please download and enjoy 🙂
Thanks, now it's working like a charm...