pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Custom Defined Lists Glitch Outputting Their Array #4478

Open adleviton opened 7 years ago

adleviton commented 7 years ago

I've set up a pod that has a few custom defined lists and they are displayed as multi-select checkboxes.

When the first item is checked, you'd get an array returned as expected:

["community_amenities"]=>
    array(4) {
      [0]=>
      string(4) "Pool"
      [2]=>
      string(10) "GolfCourse"
      [14]=>
      string(4) "Park"
      [17]=>
      string(9) "Clubhouse"
    }

However, when the first item is not checked (and more than one item is checked), you receive a multi-dimensional array.

 ["community_amenities"]=>
    array(1) {
      [0]=>
      array(3) {
        [2]=>
        string(10) "GolfCourse"
        [14]=>
        string(4) "Park"
        [17]=>
        string(9) "Clubhouse"
      }
    }

Anyone else experiencing this?

pglewis commented 7 years ago

How/where/when are you retrieving these arrays?

adleviton commented 7 years ago
$mypod = pods( 'communities', 3 ); 
$community_amenities = $mypod->get_field('community_amenities');

Above is what I have in a Wordpress template file.

pglewis commented 7 years ago

I'll see what I can find out, it's on my today/tomorrow pile.

sc0ttkclark commented 7 years ago

Be sure to use ->field not ->get_field

pglewis commented 7 years ago

@adleviton: have you had the opportunity to test if the field() method works properly for you? This could still be an issue with the deprecated get_field() but if field() works properly we can probably punt this to 2.7.1.

adleviton commented 7 years ago

Using $mypod->field instead of $mypod->get_field works just fine. Thanks!

pglewis commented 6 years ago

@sc0ttkclark: the remaining question keeping this open was whether we have a backcompat issue with get_field() that needs action.

quasel commented 6 years ago

No further discussion happened :D @sc0ttkclark can we close it?