Support Forum
Support › Meta Box Group › Nested groups conflict
Hi, I'm using nested groups in my application but I'm having trouble with the clones and the hidden/visibility conditionals.
The problem occurs when I add a cloneable group (level 3) inside a group (level 2) that is already inside a cloneable group (level 1). When I do that, is possible to delete all the cloneables group until I have a blank screen and the button '+ Add more' no longer works.
Also, if I use a conditional at this level, it also stops working.
$meta_boxes[] = array(
'title' => __( 'Metabox 1', 'textdomain' ),
'id' => 'metabox1',
'post_types' => 'rep_page',
'fields' => array(
array(
'id' => 'group1',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'fields' => array(
array(
'id' => 'select1',
'name' => __( 'Select 1', 'textdomain' ),
'type' => 'select',
'placeholder' => 'Select',
'options' => array(
1 => 'Subgroup 1',
2 => 'Subgroup 2',
),
),
array(
'id' => 'subgroup1',
'type' => 'group',
'hidden' => array('select1', '!=', 1),
'fields' => array(
array(
'id' => 'subtext1',
'name' => __( 'Subtext 1', 'textdomain' ),
'type' => 'text',
'placeholder' => 'Text',
),
),
),
array(
'id' => 'subgroup2',
'type' => 'group',
'hidden' => array('select1', '!=', 2),
'fields' => array(
array(
'id' => 'subtext2',
'name' => __( 'Subtext 2', 'textdomain' ),
'type' => 'text',
'placeholder' => 'Text',
),
array(
'id' => 'sub_subgroup1',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'max_clone' => 3,
'fields' => array(
array(
'id' => 'sub_subselect1',
'name' => __( 'Sub Sub Select 1', 'textdomain' ),
'type' => 'select',
'placeholder' => 'Select',
'options' => array(
1 => 'Sub Sub Subgroup 1',
2 => 'Sub Sub Subgroup 2',
),
),
array(
'id' => 'sub_sub_subgroup1',
'type' => 'group',
'hidden' => array('sub_subselect1', '!=', 1),
'fields' => array(
array(
'id' => 'sub_sub_subtext1',
'name' => __( 'Sub Sub Subtext 1', 'textdomain' ),
'type' => 'text',
'placeholder' => 'Text',
),
),
),
array(
'id' => 'sub_sub_subgroup2',
'type' => 'group',
'hidden' => array('sub_subselect2', '!=', 2),
'fields' => array(
array(
'id' => 'sub_sub_subtext2',
'name' => __( 'Sub Sub Subtext 2', 'textdomain' ),
'type' => 'text',
'placeholder' => 'Text',
),
),
),
),
),
),
),
),
),
),
);
Hi Lucas,
Currently, the logic of the clone is keeping the 1st entries for users to enter data. It's applied not only to groups, but also all fields.
Regarding the conditional check, have you updated both the group and conditional logic plugins to the latest version? We've just fixed a bug to make them work together.
Thanks
Anh
Hi Anh,
Thanks for the response. I'm currently using the conditional-logic v1.3 and metabox group v1.1.4.
Thanks. Let me check the Conditional Logic extension with my developer.
Dear wefit,
I've fixed Sub Sub Sub field doesn't works. Please grab the latest version (1.3.1)
Updated here, the conditional logic seems to be working now. Thanks Tan.
Still waiting for the group problem. I'm still able to delete all groups in this code example. How can I fix this?
Thanks.
I'm afraid we will keep the current logic, e.g. always keep at least 1 clone. There's no work around it at the moment.
Best regards
Anh