Post

2 followers Follow
0
Avatar

Having trouble with category integer values when creating an item

Hi everyone, I've set up an app with a 'category' field in it. I'm creating an item in my app using the API using the following code...

if(isset($_POST['how_did_you_hear_about_us'])){ 

switch ($_POST['how_did_you_hear_about_us']) 



case 'search_engine': 

$how_int = 1; 

break; 

case 'recommendation': 

$how_int = 2; 

break; 

case 'existing_customer': 

$how_int = 3; 

break; 

case 'email': 

$how_int = 4; 

break; 

case 'facebook': 

$how_int = 5; 

break; 

case 'twitter': 

$how_int = 6; 

break; 

default: 



}

$fields_array = array(); 

$fields_array['name'] = $_POST['name']; 

$fields_array['email-address'] = $_POST['email']; 

if(isset( $_POST['telephone'])){ 

$fields_array['telephone-number'] = $_POST['telephone']; 



if(isset($how_int)){ 

$fields_array['how-did-you-hear-about-us'] = $how_int; 



$fields_array['date-received'] = array('start' => $date, 'end' => $date); 

$fields_array['message'] = $_POST['feedback'];

PodioItem::create( $_POST['appid'], 

array('fields' => $fields_array), 

$options = array() 

);

Mostly it works, however I've had to change the order of the categories and the integer value assigned to them doesn't seem to have changed, for example if I send 3 through as the integer value for the category I would expect the category to be 'existing customer' but it isn't it's being set as 'email'.

Is there a way to explicitly set the integer values of the categories? Or have I missed/misunderstood something?

Andy McGill Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Andy,

The integer value (called an "option_id" in Podio language) will never change and this is actually a good thing. It means that you can rename each option in the category field without loosing data in your existing items.

If you want to re-order the options simply go into the app builder and use drag and drop to change the order of the options. They each have a little "handle" you can grab on the left side.

Does that help?

/Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Hi Andreas,

Thank you for the response, that makes sense.

Is there any way to see what the option_id for each of the categories is?

Thanks again,

Andy

Andy McGill 0 votes
Comment actions Permalink
0
Avatar

That is perfect, exactly the kind of thing I'm looking for, thank you.

Andy McGill 0 votes
Comment actions Permalink