Metabox plugin not saving the field value properly
- This topic has 6 replies, 2 voices, and was last updated 7 years, 8 months ago by
Truong Giang.
-
AuthorPosts
-
August 12, 2017 at 8:21 PM #6617
thelemonlab
ParticipantHi there,
Need some help to fix a metabox bug changing the values of the fields after I save the page.
screenshot in here: https://www.evernote.com/shard/s332/sh/b6704fb4-5066-4801-ac0b-45f9a86358d3/4295ea47d7da5ab3
The user needs to be able to select from which "Event Type" to show events from, the problem now is even if the user selects event A (example) for the first event type and event B for the second one after you save the page changes it automatically change both of the event type dropdown to the event B.
Please let me know any help with this, bit of urgency on this.
August 13, 2017 at 8:42 PM #6621thelemonlab
ParticipantCode below:
add_filter( 'rwmb_meta_boxes', 'page_events_meta_two_boxes' ); function page_events_meta_two_boxes( $meta_boxes ) { $prefix = 'thspep_two_'; // page event meta box $meta_boxes[] = array( 'id' => 'page_events_two', 'title' => 'Sencond Page Events Custom Fields', 'post_types' => 'page', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'type' => 'heading', 'name' => __( 'Second Event Type Section', 'your-prefix' ), 'id' => 'fake_id', // Not used but needed for plugin 'columns' => 12, ), array( 'name' => 'Second Event Type', 'id' => $prefix . 'event_type_option', 'type' => 'taxonomy', 'taxonomy' => 'event-type', 'field_type' => 'select_advanced', 'columns' => 6, ), array( 'name' => 'Second Feature Points', 'id' => $prefix . 'feature_points', 'type' => 'text', 'clone' => true, 'sort_clone' => true, 'columns' => 6, ), ), ); return $meta_boxes; }
August 14, 2017 at 12:05 PM #6626thelemonlab
Participantadd_filter( 'rwmb_meta_boxes', 'page_events_meta_boxes' ); function page_events_meta_boxes( $meta_boxes ) { $prefix = 'thspe_'; // page event meta box $meta_boxes[] = array( 'id' => 'page_events', 'title' => 'Page Events Custom Fields', 'post_types' => 'page', 'context' => 'normal', 'priority' => 'high', 'fields' => array( // Event Type Section array( 'type' => 'heading', 'name' => __( 'Event Type Section', 'your-prefix' ), 'id' => 'fake_id', // Not used but needed for plugin 'columns' => 12, ), array( 'name' => 'Event Module Headline', 'id' => $prefix . 'events_module_title', 'type' => 'text', 'columns' => 12, ), array( 'name' => 'Event Type', 'id' => $prefix . 'event_type_option', 'type' => 'taxonomy', 'taxonomy' => 'event-type', 'field_type' => 'select_advanced', 'columns' => 6, ), array( 'name' => 'Information Sessions Listing Points', 'id' => $prefix . 'info_session_listing', 'type' => 'text', 'clone' => true, 'sort_clone' => true, 'columns' => 6, ), ), ); return $meta_boxes; }
August 14, 2017 at 2:04 PM #6627Truong Giang
ParticipantHi there,
You must set different ids for 2 event type settings.
August 15, 2017 at 3:40 AM #6636thelemonlab
ParticipantHi,
just tried that, still doesn't work.
1.
array(
'name' => 'Event Type',
'id' => $prefix . 'event_type_option',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),2.
array(
'name' => 'Second Event Type',
'id' => $prefix . 'event_type_option_2',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),let me know any help, please.
August 15, 2017 at 3:41 AM #6637thelemonlab
ParticipantAs soon as I save the page the 1st one returns to the same value as the 2nd one.
August 15, 2017 at 8:23 AM #6638Truong Giang
ParticipantHi,
Please use the
taxonomy_advanced
field. You can read more here: https://metabox.io/docs/define-fields/#section-taxonomy
Taxonomy field does NOT save term IDs in post meta, instead of that, it only set post terms.
Taxonomy advanced field saves term IDs in post meta as a comma separated string. It does NOT set post terms. -
AuthorPosts
- You must be logged in to reply to this topic.