-
-
Save danielvonmitschke/8bc0fe942ef3df26db5f571cb2bd69ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('cmb2_admin_init', function(){ | |
$cmb = new_cmb2_box([ | |
'id' => 'cmb_repeater_metabox', | |
'title' => 'Repeateable groups', | |
]); | |
$groups = $cmb->add_field([ | |
'id' => 'cmb_groups', | |
'type' => 'group', | |
'options' => [ | |
'group_title' => 'Entry {#}', | |
'add_button' => 'Add another entry', | |
'remove_button' => 'Remove entry', | |
'sortable' => true, | |
], | |
]); | |
$cmb->add_group_field( | |
$groups, | |
[ | |
'id' => 'cmb_groups_image', | |
'name' => 'Image', | |
'type' => 'file', | |
] | |
); | |
$cmb->add_group_field( | |
$groups, | |
[ | |
'id' => 'cmb_groups_text', | |
'name' => 'Text', | |
'type' => 'textarea_small' | |
] | |
); | |
}); | |
add_filter('lg_cmb2_modals', function ($metaboxFormIds) { | |
$metaboxFormIds[] = 'cmb_repeater_metabox'; | |
return $metaboxFormIds; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window["cmb_repeater_metabox_view"] = function (model) { | |
console.log(model); | |
return "REPEATABLE GROUPS"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment