Input values not shown in back-end

Support MB Group Input values not shown in back-endResolved

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #22317
    ComSiComSi
    Participant

    I've created a cloneable group for a contact person with four fields: name/email/phone/description

    When I supply the information for two persons and save the post, both the database and frontend show the correct information. But after the page reload in the backend, the input fields have no values assigned to them.

    1) This is what I initially save to the post:

    This is what I initially save to the post

    2) This is what is saved to the database:

    This is what is saved to the database

    3) This is what is shown on the frontend when I print_r the metadata for this contact person

    This is what the frontend print_r output is

    4) But here is the problem, after saving the post in the backend the values are. not shown in the input fields:

    There is no value in the inputs here

    This is the metabox code:

    array(
        'name'       => 'Contact information',
        'id'         => 'vacancy_contact_info',
        'type'       => 'group',
        'clone'      => true,
        'sort_clone' => true,
        'fields'     => array(
            [
                'name'          => __('Name', 'vac'),
                'id'            => 'name',
                'type'          => 'text',
            ],[
                'name'          => __('Email', 'vac'),
                'id'            => 'email',
                'type'          => 'email',
            ],[
                'name'          => __('Phone', 'vac'),
                'id'            => 'phone',
                'type'          => 'text',
            ],[
                'name'          => __('Description', 'vac'),
                'id'            => 'desc',
                'type'          => 'text',
            ],
        )
    ),

    I've installed meta-box (version: 5.3.4) via Composer with MB Group (1.3.10).

    Is there something I'm missing here or is it a bug?

    #22318
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please deactivate all plugin except Meta Box and MB Group, switch to the default theme of WordPress (Twenty Twenty), add only code to show the group field, and check this issue again.

    Let me know how it goes.

    #22323
    ComSiComSi
    Participant

    Ah yes, it is a plugin compatibility problem. In the other plugin MetaBox is also embedded in the plugin via Composer. I guess we will have to find away around that. Any pointers on how to best work with two plugins? It isn't really covered in the docs (Composer & Composer Extensions).

    #22326
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Any themes or plugins can use the Meta Box as a library so if you also create your plugin and use the Meta Box, please check it if exist before running other code.

    if( ! class_exists( 'RWMB_Loader' ) ) {
        // code goes here
    }
    #22329
    ComSiComSi
    Participant

    So best practise would be to not use an autoloader for Composer but manually load in the classes if they not exist?

    #22330
    Long NguyenLong Nguyen
    Moderator

    No, the autoloader is the must use. You should check class exists before requiring the file autoloader.

    if( ! class_exists( 'RWMB_Loader' ) ) {
        require 'vendor/autoload.php';
        // code goes here
    }
    #22348
    ComSiComSi
    Participant

    That would work most of the time. But when another plugin loads RWMB without any extensions, and we need the Group-extension, how will we be able to load that?

    Wouldn't it be better to have RWMB and each extension to check for it before it loads itself?

    #22350
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I think you can load in two separate folders, one for Meta Box plugin only, one for other extensions. It also needs to create two files composer.json and run it twice. Then easy to check and require the file autoload.php.

    if( ! class_exists( 'RWMB_Loader' ) ) {
        require 'meta-box/vendor/autoload.php';
        // code goes here
    }
    
    if ( class_exists( 'RWMB_Loader' ) ) {
        require 'extensions/vendor/autoload.php';
        // code goes here
    }
    #22353
    ComSiComSi
    Participant

    That might work, thanks for the tip.

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