Problem with clonable fields and groups

Support General Problem with clonable fields and groups

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1841
    JohannJohann
    Participant

    This issue occurs with both clonable fields and groups and so I posted it into the "general" forum.

    I must query if such fields/groups have any values but it seems that this doesn't work. When I print_r() the empty field on the frontend it returns Array ( [0] => ). And sizeof() returns 1.

    Do you have any suggestions or know a workaround?

    Thanks,
    Johann

    #1852
    Anh TranAnh Tran
    Keymaster

    Hi Johann,

    For group, the value of a group is always an array. If it's cloneable, then the value is always array of arrays (2 level depth array), even when it's empty. So, for group, you should check the subvalue as well, not just empty on the group value.

    For other fields, I can't replicate the bug. There is also 1 open pull request for similar bug on Github (for oembed field), but I can't make the same bug:

    https://github.com/rilwis/meta-box/pull/703

    Do you see the same problem? Can you post your code?

    #1857
    JohannJohann
    Participant

    Ok for clonable fields it works with sizeof( array_filter( $some_meta_array ) )

    Still checking out how to check empty values for groups 🙂

    #1858
    JohannJohann
    Participant

    And for groups sizeof( array_filter( $some_meta_array[0] ) )

    Can you confirm this?

    #1860
    Anh TranAnh Tran
    Keymaster

    Hi Johann, I think yes :), the code is correct.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Problem with clonable fields and groups’ is closed to new replies.