Switch not working in MB Group

Support MB Group Switch not working in MB Group

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13849
    Brian ThurberBrian Thurber
    Participant

    All plugins are up to date. I have two switch form fields in a meta box group. When I toggle one of the switches, the post gets saved just fine. When I leave both switches un-toggled and save the post, I get an error which reads: Warning: Invalid argument supplied for foreach() in /home/umcgot/public_html/wp-content/plugins/meta-box-group/class-rwmb-group-field.php on line 240

    The switches work fine outside of the group.

    Thanks for your help! -Brian

    <?php
    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = 'umc_got_';
        $meta_boxes[] = array(
            'id'         => 'umc_got',
            'title'      => 'Game Of Thrones',
            'post_types' => 'umc_got_bracket',
            'context'    => 'normal',
            'priority'   => 'high',
    
            'fields' => array(
                array(
                    'name'   => 'Group', // Optional
                    'id'     => 'group_id',
                    'type'   => 'group',
                    // List of sub-fields
                    'fields' => array(
                        array(
                            'id'        => 'jon_snow',
                            'name'      => 'Jon Snow / Targaryen',
                            'type'      => 'switch',
                            'style'     => 'square',
                            'on_label'  => '<i class="dashicons dashicons-yes"></i>',
                            'off_label' => 'Alive',
                            'class'     => 'umc_got_switch',
                            'columns' => 4
                        ),
                        array(
                            'id'        => 'daenerys',
                            'name'      => 'Daenerys Targaryen',
                            'type'      => 'switch',
                            'style'     => 'square',
                            'on_label'  => 'Dead',
                            'off_label' => 'Alive',
                            'class'     => 'umc_got_switch',
                            'columns' => 4
                        ),
                    ),
                ),
            )
        );
        return $meta_boxes;
    }
    ?>

    This saves just fine
    This throws an error
    The Error

    #13850
    Brian ThurberBrian Thurber
    Participant

    Sorry, for some reason I can't edit the post above. In the top image, the post saves with no errors, in the second photo I get an error.

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