Support Forum
Support › Meta Box Group › sort_clone is not working at some points
Hi Tan
I use group type when creating arrays. It's much easier to read and call arrays. Below is my sample code for post meta box.
<?php
add_filter('rwmb_meta_boxes', 'my_post_meta_box');
function my_post_meta_box($meta_boxes) {
$prefix = '';
$meta_boxes[] = array(
'id' => 'my_post_meta_box_array',
'post_types' => 'post',
'tab_style' => 'left',
'tabs' => array(
'tab_1' => 'Custom Post',
'tab_2' => 'Related Post',
),
'title' => 'My Post Meta Box',
'fields' => array(
/* // CUSTOM POST
-------------------------------------------------- */
array(
'id' => 'custom_post',
'tab' => 'tab_1',
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
),
),
/* // RELATED POST
-------------------------------------------------- */
array(
'id' => 'related_post',
'tab' => 'tab_2',
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
array(
'clone' => true,
'collapsible' => true,
'id' => 'group',
'sort_clone' => true,
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
array(
'id' => 'url',
'name' => 'URL',
'type' => 'url',
),
),
),
),
),
),
);
return $meta_boxes;
}
At there, sort_clone from "RELATED POST" is not working. Probably, Javascript error?
But when I put "RELATED POST" code at the top... like below... sort_clone is working.
<?php
add_filter('rwmb_meta_boxes', 'my_post_meta_box');
function my_post_meta_box($meta_boxes) {
$prefix = '';
$meta_boxes[] = array(
'id' => 'my_post_meta_box_array',
'post_types' => 'post',
'tab_style' => 'left',
'tabs' => array(
'tab_1' => 'Custom Post',
'tab_2' => 'Related Post',
),
'title' => 'My Post Meta Box',
'fields' => array(
/* // RELATED POST
-------------------------------------------------- */
array(
'id' => 'related_post',
'tab' => 'tab_2',
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
array(
'clone' => true,
'collapsible' => true,
'id' => 'group',
'sort_clone' => true,
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
array(
'id' => 'url',
'name' => 'URL',
'type' => 'url',
),
),
),
),
),
/* // CUSTOM POST
-------------------------------------------------- */
array(
'id' => 'custom_post',
'tab' => 'tab_1',
'type' => 'group',
'fields' => array(
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
),
),
),
);
return $meta_boxes;
}
Could you please help me with that issue?
Thank you so much Tan!
Thanks, I will check it now.
Appreciate for the reply Tan.
Eagerly Waiting...
I've found the bug and fixed it in version 1.2.12 of Group extension. Please update.
Sorry for late confrim.
It works well now. Thank you so much and appreciate for the fix.
Happy Holidays Tan!
Great! Happy holidays 🙂