1

I have a Podio app which is populated by the php API via a form on a website.

Using the Create Item snippet works for text fields, currency values, etc but have been I unable to untangle the documentation as to how to set a category field.

The category field, "attending", is a simple yes/no choice.

The method shown here generates a server error when combined with Create Item snippet as below:

$fields = new PodioItemFieldCollection(array(
      new PodioTextItemField(array("external_id" => "title", "values" => $name)),
      new PodioTextItemField(array("external_id" => "email", "values" => $email)),
));

$item = new PodioItem(array(
    'app' => new PodioApp(intval($app_id)),
    'fields' => $fields,
));

pseudo code: if attending = yes, $attending = 1, else $attending = 2 //id's of yes and no in category field

$item->fields['attending']->values = $attending;

$item->save();

What am I missing? Thanks.

James
  • 311
  • 5
  • 17

2 Answers2

1

For those still searching for an answer: The trick is to use an array.

Perform the evaluation of $attending before opening the Collection and then simply add this line into the PodioItemFieldCollection.

new PodioCategoryItemField(array(
   'external_id' => 'attending', 'values' => array($attending))),

So the whole snippet would look like this

($foo == 'yes') ? $attending = 1: $attending = 2 ; // evaluating $foo for yes

$fields = new PodioItemFieldCollection(array(
  new PodioTextItemField(array("external_id" => "title", "values" => $name)),
  new PodioTextItemField(array("external_id" => "email", "values" => $email)),
  new PodioCategoryItemField(array(
    'external_id' => 'attending', 'values' => array($attending))) // must be an array
));

$item = new PodioItem(array(
'app' => new PodioApp(intval($app_id)),
'fields' => $fields,
));

$item->save();
leopold
  • 1,971
  • 1
  • 19
  • 22
-1

You can find examples at: http://podio.github.io/podio-php/fields/#category-field

If it's still not working, place podio-php into debug mode so you can see what data is being sent to Podio: http://podio.github.io/podio-php/debug/

  • Thanks Andreas, but that's the page I mentioned in the question where I took the code snippet from. The code I have generates an Internal Server Error, so no Podio debug information is available. – James Apr 16 '15 at 14:02
  • While this answer may help to solve the OP's problem, it would be better to provide a full answer. – leopold Sep 19 '17 at 22:56