Support Forum
Support › Meta Box Group › Cloning broken
Hi,
on latest version key_value field shows empty in post editing, even though it has values saved in database. It also saves values, but when returning back to the post edit screen the fields are empty. So the rendering is broken.
Looking the code, this seems to be due to $meta array structure the code loops in RWMB_Clone::html() does not work properly due to additional entry on $meta, which makes the $meta array incompatible with the code in foreach loop that is supposed to output the field. The empty entry seems to be added to $meta in RWMB_Field::meta() method, and there is comment with it:
// Always add the first item to the beginning of the array for the template.
// We will need to remove it later before saving.
array_unshift( $meta, $field['std'] );
This code is not on the previous metabox version that still works, 5.9.10.
I think this would add all cloneable fields and saw several bug reports on the forum from recent days.
Revert back to metabox version 5.9.10 until this is fixed.
If you edited a post with cloneable field it's values got rewritten into database, likely with empty array if you didn't specifically edit the cloneable field but something else and didn't notice the cloneable field was empty while saving the post.
Please fix this, thanks!
Well, description is wrong in my first post 😀
Here illustration of key_value field. On 5.9.10 it's working, see this screenshot with var_export of $meta:
Here same with 5.10.0 and there is extra array layer added at some point, also empty string as first item, and now the fields do not show in the metabox because the array structure is different what the output code expects.
In both of the images data in database is what is shown in the first attachment, without extra array layer. The data was saved with 5.9. but saving data on 5.10 doesn't work either, it goes fine into database but var_export for $meta shows the same bad data structure.
Here is how the code looks to reproduce both the images above.
As per your blog post https://metabox.io/clone-empty-start/ and comments in code let believe this empty values are added only when there is no data saved in database, but this is clearly not the case.
Please fix the bug asap. Thanks.
Hello,
Thank you for your feedback.
There is an issue with the cloneable group field in the new version of Meta Box 5.10.0 and our development team is working on it. The fix for the issue will be included in the next update of MB plugins.
Yes, thanks you! Please hurry with it, lots of problems with it as it breaks the content if someone saves a post with cloneable fields.
Hello,
Yes, please update Meta Box and MB extensions to the new version to fix the issue.
Let me know how it goes.