[Request] Force number of clones

Support MB Group [Request] Force number of clonesResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6616
    brandoobrandoo
    Participant

    Hi

    Can we add a option to force number of clones? So there will be always a fixed number of clones from the start and user will be able only to rearrange them?

    Right now I can only set the max limit of clones and there is no way to change order of separate fields.

    #6623
    Anh TranAnh Tran
    Keymaster

    Hi,

    Yes, you can do that by specified the std value. This code will set the 3 inputs (clones):

    array(
        'type' => 'text',
        'id' => 'test',
        'clone' => true,
        'max_clone' => 3,
        'std' => array( '', '', '' ) // Default values for 3 clones
    )
    #6634
    brandoobrandoo
    Participant

    Yes but it seams to only work with separate fields (not whole groups) and you still can remove or add more copies.

    #6644
    Anh TranAnh Tran
    Keymaster

    If you need to make for groups, you can set std as array of arrays of default values for sub fields, like:

    $default_for_group = array( '', '', '' ); // sub field 1, 2, 3
    'std' => array( $default_for_group, $default_for_group, $default_for_group ),

    To prevent users from removing clones, you can hide them with CSS. A simple trick is adding a custom_html field to output styles, like this:

    array(
        'type' => 'custom_html',
        'std' => '<style>.rwmb-group-wrapper .remove-clone { display: none; }</style>
    )

    You might want to add custom class to your group fields, so the CSS selector is more specific.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.