Clone Group

Support MB Group Clone Group

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1155
    xw7xw7
    Participant

    Is it possible to clone a group of fields? For example if I have 2 text boxes and 1 textarea in a group could this be cloned?

    #1156
    Anh TranAnh Tran
    Keymaster

    Yes, it is. To clone a group, please add 'clone' => true to the group field.

    #1159
    xw7xw7
    Participant

    Thanks Anh,

    Where would this be added?

    #1161
    Anh TranAnh Tran
    Keymaster

    Just in the group field, for example:

    'fields' => array(
        array(
            'id' => 'group_id',
            'type' => 'group',
            'fields' => array(
                // Sub-fields here
            ),
            'clone' => true, // This is all you need
        )
    )
    #1200
    xw7xw7
    Participant

    Will this work in the dashboard instead of editing files? Also will it allow duplication of image fields within a group so when I click clone it makes another

    Input
    Text
    Image

    >

    Input
    Text
    Image

    ?

    Thank you.

    #1207
    Anh TranAnh Tran
    Keymaster

    You mean you can edit fields without touching code? If so, we have 2 extensions for this purpose: MB Builder extension or MB Template extension.

    Regarding the text and image: yes, you can do that. You need to register a group which has 2 sub-fields: text and file_input (do not use any image fields here as they won't work for group):

    $meta_boxes[] = array(
    	'title' => 'Meta Box Title',
    	'post_types' => 'custom-post-type',
    	'fields' => array(
    		array(
    			'id' => 'group',
    			'type' => 'group',
    			'clone' => true,
    			'fields' => array(
    				array(
    					'id' => 'text',
    					'name' => 'Text',
    					'type' => 'text',
    				),
    				array(
    					'id' => 'image',
    					'name' => 'Image',
    					'type' => 'file_input',
    				),
    			),
    		),
    	),
    );
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Clone Group’ is closed to new replies.