Tab custom fields don't appear when using the code

Support MB Settings Page Tab custom fields don't appear when using the codeResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35690
    Alaan TVAlaan TV
    Participant

    I've created a new settings page that has 2 tabs, then created a new custom fields group and linked it to the first tab on the settings page. The settings page was working properly until this point.

    Then I generated the PHP code for both, the settings page and the custom fields and trashed them.

    I put the generated code in a file and included it in the functions.php file. I can see the settings page and its tabs, but no fields are showing on the settings tab.

    Here's the generated code, please advise if there's anything wrong with my code, and how to resolve the issue:

    
    <?php
    add_filter( 'mb_settings_pages', 'register_settings__admins' );
    function register_settings__admins( $settings_pages ) {
    	$settings_pages[] = [
            'menu_title'  => 'Admins Settings',
            'option_name' => 'settings_admins',
            'position'    => 25,
            'parent'      => 'options-general.php',
            'style'       => 'no-boxes',
            'columns'     => 1,
            'tabs'        => [
                'settings_admins__general_tab'      => 'General',
                'settings_admins__sticky_posts_tab' => 'Sticky Posts',
            ],
            'tab_style'   => 'left',
            'icon_url'    => 'dashicons-admin-generic',
        ];
        return $settings_pages;
    }
    
    add_filter( 'rwmb_meta_boxes', 'settings_admins_general_fields' );
    function settings_admins_general_fields( $meta_boxes ) {
        $prefix = 'settings_';
    
        $meta_boxes[] = [
            'title'          => 'settings_admins__general',
            'id'             => 'settings_admins__general',
            'settings_pages' => ['settings_admins'],
            'tab'            => 'settings_admins__general_tab',
            'fields'         => [
                [
                    'name' => 'Classic Editor',
                    'id'   => $prefix . 'classic_editor_is_active',
                    'type' => 'checkbox',
                    'desc' => 'Use the classic editor instead of the block editor.',
                ],
                [
                    'name' => 'Classic Widgets',
                    'id'   => $prefix . 'classic_widgets_is_active',
                    'type' => 'checkbox',
                    'desc' => 'Use the classic view of widgets.',
                ],
            ],
        ];
        return $meta_boxes;
    }
    
    #35702
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The generated code is missing the ID of the settings page that is required when creating a settings page. I've escalated this issue to the development team to fix it in the next update.

    add_filter( 'mb_settings_pages', 'register_settings__admins' );
    function register_settings__admins( $settings_pages ) {
    	$settings_pages[] = [
            'menu_title'  => 'Admins Settings',
            'option_name' => 'settings_admins',
            'id'          => 'settings-admins', //here
            ...
        ];
        return $settings_pages;
    }

    Read more on the documentation https://docs.metabox.io/extensions/mb-settings-page/#using-code

    #35709
    Alaan TVAlaan TV
    Participant

    Thank you! I added that line manually and it worked!

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