Custom Fields
Re-Envisioned
Support Meta Box Group Switch not working in Meta Box Group

This topic contains 1 reply, has 1 voice, and was last updated by  Brian Thurber 6 months, 3 weeks ago.

  • Creator
    Topic
  • #13849

    Brian 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

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #13850

    Brian 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 1 replies (of 1 total)

You must be logged in to reply to this topic.