diff --git a/helpers/cmb_Meta_Box_field.php b/helpers/cmb_Meta_Box_field.php
index 33cf183..ccf8ad8 100644
--- a/helpers/cmb_Meta_Box_field.php
+++ b/helpers/cmb_Meta_Box_field.php
@@ -449,7 +449,6 @@ public function _set_field_defaults( $args ) {
$args['save_id'] = 'file' == $args['type'] && ! ( isset( $args['save_id'] ) && ! $args['save_id'] );
// $args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : ( 'multicheck' == $args['type'] ? true : false );
$args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : false;
- $args['repeatable'] = isset( $args['repeatable'] ) && $args['repeatable'] && ! $this->repeatable_exception( $args['type'] );
$args['inline'] = isset( $args['inline'] ) && $args['inline'] || false !== stripos( $args['type'], '_inline' );
$args['on_front'] = ! ( isset( $args['on_front'] ) && ! $args['on_front'] );
$args['attributes'] = isset( $args['attributes'] ) && is_array( $args['attributes'] ) ? $args['attributes'] : array();
@@ -473,6 +472,12 @@ public function _set_field_defaults( $args ) {
$args['options']['textarea_name'] = $args['_name'];
}
+ if ( 'group' == $args['type'] ) {
+ $args['repeatable'] = isset( $args['repeatable'] ) ? $args['repeatable'] : true;
+ } else {
+ $args['repeatable'] = isset( $args['repeatable'] ) && $args['repeatable'] && ! $this->repeatable_exception( $args['type'] );
+ }
+
$option_types = apply_filters( 'cmb_all_or_nothing_types', array( 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ) );
if ( in_array( $args['type'], $option_types, true ) ) {
diff --git a/init.php b/init.php
index a8e1efe..012bb0b 100644
--- a/init.php
+++ b/init.php
@@ -462,8 +462,9 @@ public static function render_group( $args ) {
$group_val = (array) $field_group->value();
$nrows = count( $group_val );
$remove_disabled = $nrows <= 1 ? 'disabled="disabled" ' : '';
+ $repeatable_class = $field_group->args( 'repeatable' ) ? 'repeatable-group' : 'group';
- echo '
';
+ echo '';
if ( $desc || $label ) {
echo '';
if ( $label )
@@ -473,7 +474,7 @@ public static function render_group( $args ) {
echo ' ';
}
- if ( ! empty( $group_val ) ) {
+ if ( ! empty( $group_val ) && $field_group->args( 'repeatable' ) ) {
foreach ( $group_val as $iterator => $field_id ) {
self::render_group_row( $field_group, $remove_disabled );
@@ -482,7 +483,9 @@ public static function render_group( $args ) {
self::render_group_row( $field_group, $remove_disabled );
}
- echo ''. $field_group->options( 'add_button' ) .'
';
+ if( $field_group->args( 'repeatable' ) ) {
+ echo ''. $field_group->options( 'add_button' ) .'
';
+ }
echo '
';
@@ -510,12 +513,19 @@ public static function render_group_row( $field_group, $remove_disabled ) {
$field = new cmb_Meta_Box_field( $field_args, $field_group );
$field->render_field();
}
- echo '
+
+ // Only show the remove group button if the group is repeatable
+ if( $field_group->args( 'repeatable' ) ) {
+ echo '
id() .'_repeat" class="button remove-group-row alignright">'. $field_group->options( 'remove_button' ) .'
+ ';
+ }
+
+ echo '