Is it possible to disable the 'remove' option of a clonable group?
- This topic has 2 replies, 2 voices, and was last updated 5 years, 3 months ago by
Yard Digital.
-
AuthorPosts
-
April 19, 2020 at 9:59 PM #19054
Yard Digital
ParticipantI have built a clonable group like the following example from the docs:
https://docs.metabox.io/extensions/meta-box-group/#setting-default-group-valuesThe std values are being dynamically filled (creating about 8 group clones). I want the user to be able to change the data of each group and to reorder these clones, but not to add or delete any cloned groups.
I have been able to remove the 'add more' button by setting:
'max_clone' => 3.
Is there a way to also get rid of the option to 'remove' clones?Or is there another way to achieve what I want with metabox?
Example from the docs:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $meta_boxes[] = [ 'title' => 'Test Meta Box', 'fields' => [ [ 'type' => 'group', 'id' => 'group', 'name' => 'Group', 'clone' => true, 'collapsible' => true, 'group_title' => '{name}', 'fields' => [ [ 'type' => 'text', 'id' => 'name', 'name' => 'Name', ], [ 'type' => 'email', 'id' => 'email', 'name' => 'Email', ], ], 'std' => [ // Value for the 1st clone [ 'name' => 'Name 1', 'email' => '[email protected]', ], // Value for the 2nd clone [ 'name' => 'Name 2', 'email' => '[email protected]', ] ], ] ], ]; return $meta_boxes; } );April 20, 2020 at 2:54 PM #19160Long Nguyen
ModeratorHi there,
Unfortunately, the plugin does not support to remove the option
removein the clone group but you can use the CSS code to hide this button easily. Add this code to the file functions.php in the theme folder or use Code Snippets pluginadd_action( 'admin_footer', function() { ?> <style type="text/css"> .rwmb-group-clone .rwmb-group-remove, .rwmb-group-clone .remove-clone { display: none !important; } </style> <?php } );Let me know how it goes.
July 10, 2020 at 6:52 PM #20733Yard Digital
ParticipantHi,
Thanks for you response. Removing the clone button with display none worked for me.
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.