It would be useful to have the possibility to add groups recursively.
For example:
$group_field_id = $cmb2->add_field( array(
'id' => 'my_group_id',
'desc' => 'Group',
'type' => 'group',
) );
$cmb2->add_group_field( $group_field_id, array(
'id' => 'my_group_element_id',
'name' => 'Group Element',
'type' => 'text',
) );
$subgroup_field_id = $cmb2->add_group_field( $group_field_id, array(
'id' => 'my_subgroup_id',
'desc' => 'Subgroup',
'type' => 'group',
) );
$cmb2->add_group_field( $subgroup_field_id, array(
'id' => 'my_subgroup_element_id',
'name' => 'Subgroup Element',
'type' => 'text',
) );
Gives the following error:
( ! ) Warning: array_key_exists(): The first argument should be either a string or an integer in \cmb2\includes\CMB2.php on line 887
$subgroup_field_id is an array with
Using $subgroup_field_id[1] in the code below removes the warning, but the sub group elements still don't show (see below screenshot).
$cmb2->add_group_field( $subgroup_field_id[1], array(
'id' => 'my_subgroup_element_id',
'name' => 'Subgroup Element',
'type' => 'text',
) );

I guess this feature would need quite a bit of rewriting of the code logic that would certainly have impacts on other functions and uses, but I guess the 2 main tasks would be:
Meanwhile, a user could extends the CMB2 class and rewrite the needed functions to handle recursive groups.
Any updates on this?
related #565
Any updates on this issue. Please share if you guys found any alternative.
do you have full example of how to do custom fields + repeatable + save data correctly?
do you have full example of how to do custom fields + repeatable + save data correctly?
I have the same question
Hi guys, can you do it? :)
Most helpful comment
Any updates on this?