Support Forum
Support › Meta Box Group › Input values not shown in back-endResolved
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:
2) 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
4) But here is the problem, after saving the post in the backend the values are. not shown in the input fields:
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 Meta Box Group (1.3.10).
Is there something I'm missing here or is it a bug?
Hi,
Please deactivate all plugin except Meta Box and Meta Box 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.
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).
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
}
So best practise would be to not use an autoloader for Composer but manually load in the classes if they not exist?
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
}
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?
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
}
That might work, thanks for the tip.