Support Forum
Support › Meta Box Conditional Logic › Conditional Logic/Groups not saving properly
I'm having an issue using Conditional Logic in groups. I can clone a group, set the data, and save it. It reads fine when I reload. If I add new clones, it continues to work fine. If I re-order any of the children, it will erase some and random, and improperly order them following a page reload.
I upgraded straight from 1.01 to 1.07, so it was one of those updates that changed something.
I'm including my code below, in case you see something I'm doing wrong. Otherwise you should be able to reproduce the error.
$meta_boxes[] = array(
'id' => 'ebulletin_content',
'title' => 'Complex Content',
'post_types' => array('ebulletin'),
'context' => 'normal',
'priority' => 'high',
'columns' => 12,
'fields' => array(
array(
'id' => 'large_complex_group',
'type' => 'group',
'columns' => 12,
'clone' => true,
'sort_clone' => true,
'fields' => array(
array(
'name' => 'Content Type',
'id' => 'content_type',
'type' => 'select',
'multiple' => false,
'columns' => 2,
'std' => 'normal',
'options' => array(
'normal' => __( 'Normal', 'your-prefix' ),
'freestyle' => __( 'External', 'your-prefix' ),
'puretext' => __( 'Pure Text', 'your-prefix' ),
'pureimage' => __( 'Pure Image', 'your-prefix' ),
'banner' => __( 'Banner', 'your-prefix' ),
),
),
array(
'name' => 'Title',
'id' => 'content_title',
'type' => 'text',
'columns' => 4,
),
array( //NORMAL ONLY
'name' => 'Choose Content',
'id' => 'content_post',
'type' => 'post',
'post_type' => array('page', 'booking', 'series', 'post'),
'field_type' => 'select_advanced',
'columns' => 3,
'visible' => array('content_type', 'normal'),
),
array( //FREESTYLE ONLY
'name' => 'External Content URL',
'id' => 'external_content_link',
'type' => 'url',
'columns' => 3,
'hidden' => array('content_type', 'normal'),
),
array(
'name' => 'Upload Image',
'id' => 'external_content_image',
'type' => 'file_input',
'columns' => 12,
'visible' => array('content_type', array('freestyle', 'pureimage' ) )
),
array(
'name' => 'Subtitle',
'id' => 'content_subtitle',
'type' => 'text',
'columns' => 12,
'hidden' => array('content_type', 'pureimage'),
),
array(
'name' => 'Content Copy',
'id' => 'content_copy',
'type' => 'textarea',
'columns' => 12,
'hidden' => array('content_type', 'pureimage'),
),
)
),
)
);
Actually, after testing this a bit more, here's steps to reproduce:
Create a few items. They can be of any "content type".
Save the page.
Create a new item (New Item A).
Save the page.
Re-order the item anywhere. Notice where you leave it. I suggest re-ordering the new item into the #2 slot, just so it's easy to remember.
Save the page.
The new item is in the correct slot, right? Awesome.
Create a new item (New Item B), and leave it at the end of the list.
Save the page.
New Item B has now replaced New Item A in slot #2, and New Item A has disappeared.
Also, after this point, continuing to add a new item will continually replace the item in slot #2- New Item B will be replaced by New Item C, and so forth. If you add multiple items at once, the first New Item X will replace whatever is in slot #2, and New Item Y will fall at the end of the list.
Thanks Sam very much for reporting this bug, we're working and release the patch for Group shortly 🙂
Hi Sam,
I tested your code and tried to replicate the bug. After testing, I found that this bug was reported in this topic before. It was also reported on Github and was fixed.
I've just released the new version of Meta Box (4.5.7) which has a fix for this. The new version works fine to me. Please update Meta Box plugin and let us know if it works for you.
Thanks.