Support Forum
Support › MB Custom Table › MB Custom Table Clone Fields ErrorsResolved
Hello.
We are trying to implement the MB custom table plugin on custom post type with grouped clone fields but the plugin doesn't seems to be work. Can you please help us with this.
Array
(
[title] => floor_plans
[type] => group
[clone] => 1
[sort_clone] =>
[tab] => floor_plans
[storage_type] => custom_table
[table] => db_prefix_custom_table_name
[fields] => Array
(
[0] => Array
(
[name] => field 1
[placeholder] => fill the field
[id] => plan_title
[type] => text
[columns] => 12
)
[1] => Array
(
[name] => field 2
[placeholder] => fill the field
[id] => plan_title
[type] => text
[columns] => 12
)
[2] => Array
(
[name] => field 3
[placeholder] => fill the field
[id] => plan_title
[type] => text
[columns] => 12
)
Hi,
Two settings storage_type
and table
have to be added under the meta box settings, not the field settings.
And the group is a field type, it has to be added under the field settings.
For example:
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'Meta Box Title',
'post_types' => 'CPT',
'storage_type' => 'custom_table', // Important
'table' => 'my_custom_table', // Your custom table name
'fields' => array(
array(
'name' => 'Group', // Optional
'id' => 'group_id',
'type' => 'group',
// List of sub-fields
'fields' => array(
array(
'name' => 'Text',
'id' => 'text',
'type' => 'text',
),
// Other sub-fields here
),
),
),
);
return $meta_boxes;
}
Get more details on these documents
https://docs.metabox.io/extensions/mb-custom-table/#using-custom-tables
https://docs.metabox.io/extensions/meta-box-group/
Thanks for your response. Does this solution works for clone grouped fields also. we would like to have multiple rows against single custom post type. Is that also possible?
Hi,
Yes, it works for the cloneable group field. All sub-fields and cloneable groups will be stored in one cell of the row. Each row will store field value for one post ID.