Post

2 followers Follow
0
Avatar

Creating/updating a category with text is not working.

Creating or updating a category field will not change it's text value. It will continue to stay blank. I have currently tried creating the field with the 'options' tag into an array, with no results and then tried to just update the field again with the 'options' tag, same result.

 

Latest code for creating: 

$fieldattributes = array('type' => 'category', 'config' => [
    'label' => 'Category',
    'required' => false,
    'options' => [
        'text' => 'value',
    ]
]);

PodioAppField::create( $app_id, $fieldattributes );

 

I can easily create the app with the label, it just will not take the options attribute and apply a value

Oliver Gamborg

Please sign in to leave a comment.

3 comments

1
Avatar

Hi Oliver,

Try this:

$fieldattributes = array('type' => 'category', 'config' => [
'label' => 'Category',
'required' => false,
'settings' => [
'options' => [
[
'text' => 'value',
]
]
]
]);

br
Marek

Marek Hruzik 1 vote
0
Avatar

Hey Marek, thanks for the help it works. Can you explain the workflow a bit? I don't seem to understand how this works out, specifically in the double options array?

 

This:

'settings' => [
'options' => [
[
'text' => 'value',
]
]
]

is the equivalent to

 'settings' => [
'options' => [[
'text' => 'value',
]]
]

right?

So why make an array inside an array?
Oliver Gamborg 0 votes
0
Avatar

Take a look at "category" section in applications documentation - "options" is a collection of option objects. It looks like this in JSON format:

options = [
{ "text": "option 1" , "color": "..." },
{ "text": "option 2" , [..] },
{ "text": "option 3" , [..] }
]

br
Marek

Marek Hruzik 0 votes