Forum Replies Created
-
AuthorPosts
-
Marius Günter
ParticipantStill have a error with breakdance since latest Update.
January 5, 2023 at 5:29 PM in reply to: ✅taxonomy_advanced for settings does not save data any more #40127Marius Günter
Participant...or is there a quick fix / patch?
January 5, 2023 at 5:22 PM in reply to: ✅taxonomy_advanced for settings does not save data any more #40126Marius Günter
ParticipantHi there,
I have the same problem.
I have a settings page with a group. Inside that group there is a taxonomy_advanced field.
When I save the settings page, the selected values of the taxonomy_advanced field aren't saved anymore.When does it be fixed?
[ 'name' => '', 'id' => 'options_cat', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'add_button' => 'Hinzufügen', 'fields' => [ [ 'name' => 'Posttype', 'id' => 'cpt', 'type' => 'select', 'options' => [ 'video' => 'Video', 'podcast' => 'Podcast', 'event' => 'Termin', 'post' => 'Blog', 'forum' => 'Forum', ], 'columns' => 2, ], [ 'name' => 'Kategorien', 'id' => 'terms', 'type' => 'taxonomy_advanced', 'taxonomy' => ['category'], 'field_type' => 'checkbox_list', 'placeholder' => 'Kategorie auswählen', 'multiple' => true, 'columns' => 10, ], ], ],Marius Günter
ParticipantI am facing the exact same problem.
After going through the code, I came to the conclusion, that it is currently not possible.
First of all, you cannot set a default of '0' (type=string). Internally the std value is checked against
empty()(see RWMB_Group_Field::child_field_std). Unfortunately,empty( '0' ) === true.Next, Metabox' client-side cloning completely ignores hidden fields (see https://github.com/wpmetabox/meta-box/blob/master/js/clone.js#L91-L102). The cloning is implemented by copying the HTML of the previous element and then applying some functions on the newly inserted fields. Usually, at that time, the default values are set.
Marius 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