Want to select a single check box

Support General Want to select a single check boxResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #19248
    arifur rahmanarifur rahman
    Participant

    Hello, we want to select default only one option https://prnt.sc/s4ppih right now user able to checked two filed. we want to do that like your meta genrator select filed balue our code is

    array(
        'id'     => $prefix .'switcher_group',
        'type'   => 'group',
        'clone'  => true,
        'sort_clone' => true,
        'fields' => array(
            // Normal field (cloned)
            array(
                'name'    => 'Value',
                'id'      =>  $prefix .'switcher_value',
                'type'    => 'text',
                'columns' => 4,
            ),
            array(
                'name'    => 'Label',
                'id'      => $prefix .'switcher_label',
                'type'    => 'text',
                'columns' => 4,
            ),
            array(
                'id' => $prefix . 'select_default',
                'name' => esc_html__( 'Checkbox', 'metabox-online-generator' ),
                'type' => 'checkbox',
                'columns' => 4,
            ),
        ),
        'hidden' => array( $prefix . 'select', '!=', 'switch' ),
    ),
    #19253
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Because the field checkbox is inside the field group so when we add a new group (clone) the checkbox also generated. You can drag and drop the checkbox field above the group field or delete and create a new one, see my screen record.

    Or change the code to

    array(
        'id' => $prefix . 'select_default',
        'name' => esc_html__( 'Checkbox', 'metabox-online-generator' ),
        'type' => 'checkbox',
    ),
    array(
        'id'     => $prefix .'switcher_group',
        'type'   => 'group',
        'clone'  => true,
        'sort_clone' => true,
        'fields' => array(
            // Normal field (cloned)
            array(
                'name'    => 'Value',
                'id'      =>  $prefix .'switcher_value',
                'type'    => 'text',
                'columns' => 6,
            ),
            array(
                'name'    => 'Label',
                'id'      => $prefix .'switcher_label',
                'type'    => 'text',
                'columns' => 6,
            ),
        ),
        'hidden' => array( $prefix . 'select', '!=', 'switch' ),
    ),
    #19269
    arifur rahmanarifur rahman
    Participant

    Thank you for your reply but we want to achieve like this https://prnt.sc/s5868a

    There will be multiple values and we will assign which one will be the selected default value.

    #19271
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you want to create options for the select field in MB Builder, just type the pair value: label in the Choice area and Default value for default. Please see my screenshot https://cl.ly/6c6440db3804

    #19281
    arifur rahmanarifur rahman
    Participant

    Hello, did you saw my message we want same like your demo builder select option did you put default value? our one is dynamic user can add the option and set this value is default then we will populate in front. do you understand my Please check our metabox builder and then click select value option

    thank you

    #19288
    Long NguyenLong Nguyen
    Moderator

    Hi,

    We can only set the default value for the first clone item when loaded, after that the user can check multiple boxes. However, thanks for the idea, I will create a feature request to support this case. At this time, you can pop the first value of the array to show as the default value if the user checks multiple boxes.

    Thanks for your patience.

    #19289
    arifur rahmanarifur rahman
    Participant

    Hello, thank you for your message, is the online generator your team create can be the product from our metabox end or that is custom

    thank you

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