- This topic has 2 replies, 2 voices, and was last updated 5 years, 1 month ago by
cyclissmo.
-
AuthorPosts
-
-
December 21, 2016 at 6:19 pm #7682
cyclissmoMemberHey guys, have a little problem here with an add-more field that has me scratching my head.
I have an add-more field that serializes it’s data. It works normally when I add values to it. When I remove a value, it does not display some of the values on the edit page, even though they exist in the database. When I check the serialized data in the database, I see the correct field data, but I notice that the array keys have gaps, which I presume is confusing the field renderer?
Here is my field code:
piklist( 'field', array( 'type' => 'group', 'label' => false, 'description' => $description, 'field' => 'staff_departments', 'scope' => 'post_meta', 'serialize' => true, 'add_more' => true, 'fields' => array( array( 'type' => 'select', 'field' => 'term_id', 'value' => '', 'label' => 'Department', 'choices' => array( '' => '' ) + $options, ), array( 'type' => 'text', 'field' => 'sort', 'label' => 'Sort', 'value' => '', ), array( 'type' => 'group', 'field' => 'roles', 'add_more' => true, 'fields' => array( array( 'type' => 'text', 'field' => 'role', 'label' => false, 'value' => '', ), ) ) ) ) );Assuming there are four values, and I remove the third one, after saving this is what I see in the database (note the gap in array keys):
Array ( [0] => Array ( [term_id] => 21 [sort] => [roles] => Array ( [0] => Array ( [role] => ) ) ) [1] => Array ( [term_id] => 23 [sort] => [roles] => Array ( [0] => Array ( [role] => ) ) ) [3] => Array ( [term_id] => 5 [sort] => [roles] => Array ( [0] => Array ( [role] => ) ) ) )Any ideas what might be causing this weirdness?
-
December 22, 2016 at 11:22 am #7690
SteveKeymaster@cyclissmo– Looks like you found a bug. I’ll add it to the list we’re working on, but I’m not sure it will get fixed quickly. We’re still fixing older bugs and writing unit tests.
-
December 22, 2016 at 1:04 pm #7691
cyclissmoMemberThanks for checking in on it, Steve.
For now I can just tap into one of the many postmeta filters to re-index the array (assuming that’s what is causing the problem!) I’ll update this post if I discover anything new.
-
-
AuthorPosts
- You must be logged in to reply to this topic.