PodioApp::fields_of_type not working...
I am trying to call this on an "App" $contactFields = $anApp->fields_of_type('contact'); Just like we can call this on an "Item" $contactFields = $anItem->fields_of_type('contact'); I get this error: Warning: Invalid argument supplied for foreach() in C:\\\\git\\\\podiohelpdesk\\\\helpdesk\\\\libs\\\\PodioAPIV3\\\\models\\\\PodioSuperApp.php on line 56   It would be killer if we could call this also... I am trying to get a list of all the field definitions defined for the app that are of type "contact"... this would be a handy way to do this...  Thanks! Patrick Steil http://www.podiotools.com

  • Indeed, doing a full "get" on the item worked... perhaps you can detect this condition in the code and give the developer a more meaningful message? Thanks, patrick
  • Hi Patrick, If you look at the method in question you can see that it's a simple one: https://github.com/podio/podio-php/blob/master/models/PodioSuperApp.php#L51-L62 It's just a convenience method that goes through the "fields" property to pull out the fields that match your criteria. The API doesn't always return full app or item objects for performance reasons. E.g. when getting an item you get a mini version of an app returned along with it, but that mini version doesn't contain all the app fields. We already have substantial data to return so we try to minimize what extra data we send. The error you're getting is apparent when you look at the line in question. Line 56 attempts to iterate over the contents of the fields property, but in your case the data you have doesn't contain the fields so you get an error. So in this case you need to grab a full version of the app and/or item since that API operation will return the full object including all fields. All the best, Andreas
  • Actually this does work when you have a fully retrieved App using PodioApp::get, but when you get the App using: $reference = PodioReference::resolve(array('url' => $url)); $theApp = new PodioApp($reference->data); Then the fields_of_type() function doesn't work... what are we missing? Patrick
This question is closed.