Creating/updating a category with text is not working.

Comments

3 comments

  • Marek Hruzik

    Hi Oliver,

    Try this:

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

    br
    Marek

    1
    Comment actions Permalink
  • Oliver Gamborg

    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?
    0
    Comment actions Permalink
  • Marek Hruzik

    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

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk