Three selects with categories do not save all
Support › MB Frontend Submission › Three selects with categories do not save allResolved
- This topic has 7 replies, 2 voices, and was last updated 3 years, 4 months ago by
Steffen Larsen.
-
AuthorPosts
-
December 2, 2021 at 1:35 AM #32338
Steffen Larsen
ParticipantI have three select boxes with different category-children (child_of as query args) but when i save the fields, not all of them gets saved in DB. What am i doing wrong?
December 2, 2021 at 9:45 AM #32346Long Nguyen
ModeratorHi Steffen,
Can you please share the code that creates the custom fields? I will check it on my end.
December 2, 2021 at 2:54 PM #32352Steffen Larsen
Participant<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Produkt info', 'your-text-domain' ), 'id' => 'produkt-info', 'post_types' => ['produkt'], 'fields' => [ [ 'name' => __( 'Produkttype', 'your-text-domain' ), 'id' => $prefix . 'produkttype', 'type' => 'taxonomy', 'taxonomy' => ['category'], 'field_type' => 'select_advanced', 'remove_default' => true, 'required' => true, 'query_args' => [ 'child_of' => 4, ], ], [ 'name' => __( 'Dage på auktion', 'your-text-domain' ), 'id' => $prefix . 'dage_paa_auktion', 'type' => 'number', 'max' => 21, 'append' => 'Dage', 'visible' => [ 'when' => [['produkttype', '=', 7]], 'relation' => 'or', ], ], [ 'name' => __( 'Startpris', 'your-text-domain' ), 'id' => $prefix . 'startpris', 'type' => 'number', 'min' => 0, 'max' => 100000, 'append' => 'DKK', 'visible' => [ 'when' => [['produkttype', '=', 7]], 'relation' => 'or', ], ], [ 'name' => __( 'Bud step', 'your-text-domain' ), 'id' => $prefix . 'bud_step', 'type' => 'number', 'max' => 500, 'visible' => [ 'when' => [['produkttype', '=', 7]], 'relation' => 'or', ], ], [ 'name' => __( 'Max Pris', 'your-text-domain' ), 'id' => $prefix . 'max_pris', 'type' => 'number', 'min' => 0, 'max' => 100000, 'append' => 'DKK', 'visible' => [ 'when' => [['produkttype', '=', 5]], 'relation' => 'or', ], ], [ 'name' => __( 'Pris', 'your-text-domain' ), 'id' => $prefix . 'pris', 'type' => 'number', 'min' => 0, 'max' => 100000, 'visible' => [ 'when' => [['produkttype', '=', 6]], 'relation' => 'or', ], ], [ 'name' => __( 'Beskrivelse', 'your-text-domain' ), 'id' => $prefix . 'beskrivelse', 'type' => 'textarea', 'required' => true, ], [ 'name' => __( 'Billeder', 'your-text-domain' ), 'id' => $prefix . 'billeder', 'type' => 'image_upload', 'max_file_uploads' => 4, ], [ 'name' => __( 'Betalingsmidler', 'your-text-domain' ), 'id' => $prefix . 'betalingsmiddel', 'type' => 'taxonomy', 'taxonomy' => ['category'], 'field_type' => 'select_advanced', 'remove_default' => true, 'multiple' => true, 'required' => true, 'query_args' => [ 'child_of' => 36, ], ], [ 'name' => __( 'Forsendelsesmuligheder', 'your-text-domain' ), 'id' => $prefix . 'forsendelsesmulighed', 'type' => 'taxonomy', 'taxonomy' => ['category'], 'field_type' => 'select_advanced', 'remove_default' => true, 'multiple' => true, 'required' => true, 'query_args' => [ 'child_of' => 28, ], ], [ 'name' => __( 'Auktionen er slut', 'your-text-domain' ), 'id' => $prefix . 'auktionen_er_slut', 'type' => 'switch', 'style' => 'rounded', 'on_label' => 'Ja', 'off_label' => 'Nej', 'attributes' => [ 'readonly' => true, ], 'visible' => [ 'when' => [['produkttype', '=', 7]], 'relation' => 'or', ], ], ], ]; return $meta_boxes; }
December 2, 2021 at 2:55 PM #32353Steffen Larsen
Participant"Produkttype", "Betalingsmidler", "Forsendelsesmuligheder" only the last one gets saved.
December 2, 2021 at 10:48 PM #32370Long Nguyen
ModeratorHi,
The field
taxonomy
sets the post terms, so there will be one fieldcategory
work. If you want to save data for 3 fields, please use the field typetaxonomy_advanced
.Read more on the documentation
https://docs.metabox.io/fields/taxonomy/#data
https://docs.metabox.io/fields/taxonomy-advanced/December 3, 2021 at 5:26 AM #32382Steffen Larsen
ParticipantNope it still doesn't save anything but the last. I tried everything in the docs.
December 3, 2021 at 10:57 PM #32409Long Nguyen
ModeratorHi,
Have you tried to use the field type
taxonomy_advanced
? I do not see any issue with this field type on my site.December 4, 2021 at 6:42 AM #32415Steffen Larsen
ParticipantYes i tried it, but i had a fieldgroup with the same names. I deleted them, but maybe it's the problem. Maybe i should start over and test it on a fresh install. But thanks anyway.
-
AuthorPosts
- You must be logged in to reply to this topic.