Support Forum
Support › Meta Box Group › Select fields do not show values in Meta Box GroupResolved
Hi Anh,
I found a bug in Meta Box Group somewhere between version 1.3.4 and 1.3.11
In the group-fields.php
file the filter of line 83 was changed from rwmb_field_meta
to rwmb_raw_meta
and that makes my group fields not load the values when it comes to select fields. They are saved in the database but they are not shown in the select fields.
I couldn't check the exact version on GitHub because I guess the repository is private.
Can you review it?
Thank you
Hi,
Yes, the filter change from version 1.3.9. Please take some screenshots of the issue and share the code that created the group, I will try to reproduce the issue on my end.
I'm trying to leave a comment and after a certain amount of characters I get "Error: Your reply cannot be edited at this time."
Hi,
Have you tried to leave a new comment?
Hi Clayton,
I've received your ticket via Freshdesk:
I keep getting an error when trying to submit more information on this bug. I hope all of this information goes through fine.
To recreate this issue,
- Install Metabox and MB Groups on WP.
- Register the group field.
- Register the taxonomy.
- Create taxonomy terms.
- Create a post.
- Select a taxonomy term with the select field in the group field.
- Save the post.
- Refresh the page.
What you will see is the select field has no value but the database stored the proper value from the select field. The new raw filter for the group field is preventing the field from showing the actual value. Please have a look at the first comment from this ticket to see where we think the problem is.
The field taxonomy
doesn’t store any terms in the post meta. Instead, it sets post terms. Just like a replacement of Category or Tag meta box of WordPress so it does not work with Group. If you want to save the taxonomy as the post meta, please use the field taxonomy_advanced
.
For more information, please follow these documentations.
https://docs.metabox.io/fields/taxonomy-advanced/
https://docs.metabox.io/fields/taxonomy/#data
Thanks for this information Long. We had it working fine for a long time until this last update of that plugin. I switch the field type and everything works like in the past. Thank you for the help. Please close this ticket.
Hi,
you could use a workaround. Use a simple "Select" field and fill the options with the term data from get terms. To get the terms use get_terms inside the "init" action hook.
For Example:
add_filter( 'init', function() {
$terms = get_terms(
[
'taxonomy' => 'THE_TAXONOMY',
'hide_empty' => false
]
);
$terms_data = [];
foreach( $terms as $term ) {
$terms_data[ $term->term_id ] = $term->name;
}
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) use ( $terms_data ) {
meta_boxes[] = [
'title' => 'THE_METABOX',
'post_types' => 'THE_POSTTYPE',
'fields' => [
[
'name' => 'THE_FIELD_NAME',
'id' => 'THE_FIELD_ID',
'type' => 'group',
'fields' => [
[
'name' => 'THE_SELECT_FIELD_NAME',
'id' => 'THE_SELECT_FIELD_ID',
'type' => 'select',
'options' => $terms_data,
],
]
],
];
return $meta_boxes;
});
}