Switch On default renders off on user profile

Support General Switch On default renders off on user profileResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24511
    Dragan MarianDragan Marian
    Participant

    Hi,

    I have a custom group using the code below.
    as can be seen, the switch 'std' value is true, which should render the switch as on, by default but renders off.

    Case 2:
    A few days ago I had another situation where 'std' was on, the group in which the switch was in was cloneable. The first switch was on, but when I cloned the parent group, the other switch buttons were off. I could not reproduce this case as I cannot remember the exact settings.

    function user_stores( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'  => __( 'User Stores', 'your-text-domain' ),
            'id'     => 'custom-fields-group-user-stores',
            'type'   => 'user',
            'fields' => [
                [
                    'name'              => __( 'User Stores', 'your-text-domain' ),
                    'id'                => $prefix . 'user_stores',
                    'type'              => 'group',
                    'clone'             => true,
                    'clone_as_multiple' => true,
                    'add_button'        => __( 'Add Store', 'your-text-domain' ),
                    'fields'            => [
                        [
                            'name'       => __( 'Store', 'your-text-domain' ),
                            'id'         => $prefix . 'store',
                            'type'       => 'post',
                            'post_type'  => ['store'],
                            'field_type' => 'select_advanced',
                            'required'   => true,
                        ],
                        [
                            'name' => __( 'Active', 'your-text-domain' ),
                            'id'   => $prefix . 'active',
                            'type' => 'switch',
                            'std'  => true,
                        ],
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    #24516
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your reporting. I'm going to check this case and inform you later.

    #24525
    Anh TranAnh Tran
    Keymaster

    Hi Dragan,

    Thanks for your feedback. There's a bug when setting the default value for sub field in a group with clone = true and clone_as_multiple = true. I've fixed it here and it will be added in the next version.

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