Custom Fields
Re-Envisioned
Support General Problem with clonable fields and groups

  • Creator
    Topic
  • #1841
    Johann
    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #1852
    Anh 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
    Johann
    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
    Johann
    Participant

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

    Can you confirm this?

    #1860
    Anh Tran
    Keymaster

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

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