Select fields do not show values in MB Group
- This topic has 6 replies, 3 voices, and was last updated 3 years, 6 months ago by
Marius Günter.
-
AuthorPosts
-
November 6, 2020 at 3:04 AM #22727
Content Pilot
ParticipantHi Anh,
I found a bug in MB Group somewhere between version 1.3.4 and 1.3.11
In the
group-fields.php
file the filter of line 83 was changed fromrwmb_field_meta
torwmb_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 youNovember 6, 2020 at 3:02 PM #22731Long Nguyen
ModeratorHi,
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.
November 10, 2020 at 8:22 PM #22787Content Pilot
ParticipantI'm trying to leave a comment and after a certain amount of characters I get "Error: Your reply cannot be edited at this time."
November 12, 2020 at 9:00 AM #22813Long Nguyen
ModeratorHi,
Have you tried to leave a new comment?
November 13, 2020 at 11:03 AM #22831Long Nguyen
ModeratorHi 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 fieldtaxonomy_advanced
.For more information, please follow these documentations.
https://docs.metabox.io/fields/taxonomy-advanced/
https://docs.metabox.io/fields/taxonomy/#dataNovember 14, 2020 at 2:37 AM #22846Content Pilot
ParticipantThanks 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.
October 31, 2021 at 12:18 AM #31656Marius Günter
ParticipantHi,
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; }); }
-
AuthorPosts
- You must be logged in to reply to this topic.