Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address field type #16

Open
bbmatt opened this issue Jul 29, 2015 · 2 comments
Open

address field type #16

bbmatt opened this issue Jul 29, 2015 · 2 comments

Comments

@bbmatt
Copy link

bbmatt commented Jul 29, 2015

I've noticed with the address field type, if the values are empty, the array keys are still added IF the field type is set to repeatable in the metabox.

This becomes problematical when checking to see if an array is empty or not.
If I'm looping through a repeatable cmb2 metabox that's using an address field for each entry for instance.

Shouldn't the array keys be unset if there's no value in them?

@jtsternberg
Copy link
Member

if you do something like $value = array_filter( $value ), you can check if empty( $value ) as it will filter out array keys that have no value.

@bbmatt
Copy link
Author

bbmatt commented Jul 30, 2015

Sure, tried that, unfortunately the order of the structure of my code is such that the custom snippet I've created (based on this address one), is just one of a number of fields in a group repeatable structure. That repeatable structure is also surrounded by structural html specific to it, that's not within a loop.

The upshot is, I'm checking for empty on the array that holds the custom fields array - so array_filter doesn't work as expected.

Everything works as expected if the custom field isn't set as repeatable - so I've got around it by just replicating as many fields as I may possibly require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants