Select Advanced is not empty when cloned.
- This topic has 3 replies, 3 voices, and was last updated 10 months, 2 weeks ago by
phil.
-
AuthorPosts
-
October 13, 2023 at 11:42 PM #43523
Michael O'Quin
ParticipantI have a "Group" that has a field type of "Post" that I amusing "Select Advanced". When I DO NOT have "Multiple" enabled everything works as expected. When I clone the group the field is empty.
When I have "Multiple" enabled and I clone the group the field has the last value that I had entered.
I believe this problem was discussed in 2016 "https://support.metabox.io/topic/select-advance-clone-issue/?swcfpc=1" and again in "https://support.metabox.io/topic/select-advance-clone-issue-2/?swcfpc=1".
I don't understand why the bug still exists in 2023, it should have been rolled out with any one of the many updates.
Here is the code:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Event', 'your-text-domain' ), 'id' => 'event', 'post_types' => ['event'], 'fields' => [ [ 'name' => __( 'Description', 'your-text-domain' ), 'id' => $prefix . 'description', 'type' => 'wysiwyg', ], [ 'name' => __( 'Location', 'your-text-domain' ), 'id' => $prefix . 'location', 'type' => 'post', 'post_type' => ['location'], ], [ 'name' => __( 'Schedule', 'your-text-domain' ), 'id' => $prefix . 'schedule', 'type' => 'group', 'collapsible' => true, 'default_state' => 'collapsed', 'group_title' => '{schedule_item}', 'clone' => true, 'sort_clone' => true, 'fields' => [ [ 'name' => __( 'Schedule Item', 'your-text-domain' ), 'id' => $prefix . 'schedule_item', 'type' => 'text', 'required' => true, ], [ 'name' => __( 'Host', 'your-text-domain' ), 'id' => $prefix . 'host', 'type' => 'post', 'post_type' => ['speaker'], 'field_type' => 'select_advanced', 'multiple' => true, 'placeholder' => __( 'Select Host', 'your-text-domain' ), ], [ 'name' => __( 'Date', 'your-text-domain' ), 'id' => $prefix . 'date', 'type' => 'date', ], [ 'name' => __( 'All Day', 'your-text-domain' ), 'id' => $prefix . 'all_day', 'type' => 'switch', 'style' => 'rounded', 'on_label' => 'Yes', 'off_label' => 'No', 'std' => true, 'columns' => 3, ], [ 'name' => __( 'Start Time', 'your-text-domain' ), 'id' => $prefix . 'start_time', 'type' => 'time', 'columns' => 4, 'hidden' => [ 'when' => [['all_day', '=', true]], 'relation' => 'and', ], ], [ 'name' => __( 'End Time', 'your-text-domain' ), 'id' => $prefix . 'end_time', 'type' => 'time', 'std' => '{start_time}', 'columns' => 4, 'hidden' => [ 'when' => [['all_day', '=', true]], 'relation' => 'or', ], ], ], ], ], ]; return $meta_boxes; }
October 13, 2023 at 11:52 PM #43524Michael O'Quin
ParticipantAdditionally I am also having a problem with the "Switch" field. I have it set to be on by default but when it is cloned it is off.
October 16, 2023 at 8:40 PM #43532Peter
ModeratorHello,
Thanks for your feedback.
I see the issue with the
post
field, I've escalated this issue to the development team to fix it in future updates.Regarding the
switch
field, if you want to clone default value, please enableclone_default
for the group field. Following the documentation https://docs.metabox.io/extensions/meta-box-group/#clone-default-valuesJune 5, 2024 at 8:23 PM #45620phil
ParticipantI can confirm I am seeing the same problem. Hope it gets fixed soon.
-
AuthorPosts
- You must be logged in to reply to this topic.