Title: group for non-repeatable fields
Last modified: August 9, 2017

---

# group for non-repeatable fields

 *  Resolved [arpitap](https://wordpress.org/support/users/arpitap/)
 * (@arpitap)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/)
 * Hi there,
 * I show in [this](https://github.com/CMB2/CMB2/issues/93) article that you mentioned
   that group for non-repeatable fields are possible now, but I can’t see any documentation
   on how we can add that.
 * I tried to add as below but when it is being saved it creates 3 copy of the same
   fields.
 *     ```
       $tools_metabox->add_field( [
       		'id'         => 'test',
       		'type'       => 'group',
       		'repeatable' => false, // Repeatable fields are supported w/in repeatable groups (for most types)
       		'fields'      => [
             [
       				'name' => 'test 1',
       				'id'   => 'point_0',
               'type' => 'wysiwyg',
       				'before'     => sprintf( '<span class="description">%1$s</span><span data-max-chars="80" data-count-id="_test_point_0">%2$s</span>',
       						__( 'Max. 15-30 words.', '' ),
       						MaxCharacters\get_character_count_markup( 80, '' )
       				),
       				'options'    => [
       		      'wpautop'        => true,
       		      'textarea_name'  => 'point_0',
       		      'textarea_rows'  => 3,
       		      'teeny'          => false,
       		      'default_editor' => 'tinymce',
       		      'media_buttons'  => false,
       		      'quicktags'      => true,
       		      'tinymce'        => [
       		        'resize'                => false,
       		        'wordpress_adv_hidden'  => false,
       		        'add_unload_trigger'    => false,
       		        'statusbar'             => false,
       		        'wp_autoresize_on'      => false,
       		        'verify_html'           => false, // Prevent deleting default empty tags.
       		        'toolbar1'              => 'bold,italic,link,unlink',
       		        'toolbar2'              => '',
       		      ],
       				],
       				'classes'=> [
       					'test-row',
       				],
             ],
       			[
       				'name' => 'Test 2',
       				'id'   => 'point_1',
               'type' => 'wysiwyg',
       				'before'     => sprintf( '<span class="description">%1$s</span><span data-max-chars="80" data-count-id="_test_point_1">%2$s</span>',
       						__( 'Max. 15-30 words.', '' ),
       						MaxCharacters\get_character_count_markup( 80, '' )
       				),
       				'options'    => [
       		      'wpautop'        => true,
       		      'textarea_name'  => 'point_1',
       		      'textarea_rows'  => 3,
       		      'teeny'          => false,
       		      'default_editor' => 'tinymce',
       		      'media_buttons'  => false,
       		      'quicktags'      => true,
       		      'tinymce'        => [
       		        'resize'                => false,
       		        'wordpress_adv_hidden'  => false,
       		        'add_unload_trigger'    => false,
       		        'statusbar'             => false,
       		        'wp_autoresize_on'      => false,
       		        'verify_html'           => false, // Prevent deleting default empty tags.
       		        'toolbar1'              => 'bold,italic,link,unlink',
       		        'toolbar2'              => '',
       		      ],
       				],
       				'classes'=> [
       					'test-row',
       				],
             ],
       			[
       				'name' => 'Test 3',
       				'id'   => 'point_2',
               'type' => 'wysiwyg',
       				'before'     => sprintf( '<span class="description">%1$s</span><span data-max-chars="80" data-count-id="_test_point_2">%2$s</span>',
       						__( 'Max. 15-30 words.', '' ),
       						MaxCharacters\get_character_count_markup( 80, '' )
       				),
       				'options'    => [
       		      'wpautop'        => true,
       		      'textarea_name'  => 'point_2',
       		      'textarea_rows'  => 3,
       		      'teeny'          => false,
       		      'default_editor' => 'tinymce',
       		      'media_buttons'  => false,
       		      'quicktags'      => true,
       		      'tinymce'        => [
       		        'resize'                => false,
       		        'wordpress_adv_hidden'  => false,
       		        'add_unload_trigger'    => false,
       		        'statusbar'             => false,
       		        'wp_autoresize_on'      => false,
       		        'verify_html'           => false, // Prevent deleting default empty tags.
       		        'toolbar1'              => 'bold,italic,link,unlink',
       		        'toolbar2'              => '',
       		      ],
       				],
       				'classes'=> [
       					'test-row',
       				],
             ],
           ]
       	] );
       ```
   
 * Can you please advise what am I doing wrong?
    -  This topic was modified 8 years, 9 months ago by [arpitap](https://wordpress.org/support/users/arpitap/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9393225)
 * Hi [@arpitap](https://wordpress.org/support/users/arpitap/).
 * I’m not quite sure what the issue is here. I have pasted the group field provided
   into my local install. When the `'repeatable' => false` detail is provided, the“
   remove group” and “add group” buttons are removed from the UI. When I remove 
   that “repeatable” line, those two buttons return. From what I can infer with 
   the referenced change to the plugin, it’s doing what it should be. Grouping some
   meta fields together, but not allowing them to be repeated in the UI. All 3 wysiwyg
   fields in the group are saving individual values for me.
 * Just in case it’s a contributing issue, have you made sure to update to the latest
   version of the plugin?
 *  Thread Starter [arpitap](https://wordpress.org/support/users/arpitap/)
 * (@arpitap)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9393281)
 * Hi Michael,
 * Thanks for the quick response.
 * the fields are added as expected when I go in new Article – [https://www.dropbox.com/s/1ynhgj1w2w48j2w/before-saving.jpg?dl=0](https://www.dropbox.com/s/1ynhgj1w2w48j2w/before-saving.jpg?dl=0)
 * once I publish and then come back to the article, it save as below –
    [https://www.dropbox.com/s/ksisgahoqp7ccs6/after-saving.jpg?dl=0](https://www.dropbox.com/s/ksisgahoqp7ccs6/after-saving.jpg?dl=0)
 *  Thread Starter [arpitap](https://wordpress.org/support/users/arpitap/)
 * (@arpitap)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9393391)
 * it is adding 3 values in the DB, 1st one as single array of 3 objects
    other 
   2 are 1 array with sub-array of 3 objects
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9394628)
 * Not managing to recreate this, at least with the snippet provided. Can you provide
   the entirety of your CMB2 config code? Something outside of this one field may
   be playing a part in what you’re seeing.
 *  Thread Starter [arpitap](https://wordpress.org/support/users/arpitap/)
 * (@arpitap)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9407033)
 * it was doing what it was supposed to do.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9408311)
 * So there’s no more issue at the moment?

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘group for non-repeatable fields’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/group-for-non-repeatable-fields/#post-9408311)
 * Status: resolved