Adding a New Option to a Category Field

Comments

2 comments

  • Marek Hruzik

    Hi Ashwin,

    The 'update' method updates the 'config' of a field. So your request should look something like this:

    $fieldAttributes = array (
    'label' => 'Status',
    'required' => false,
    'settings' => [
    'multiple' => false,
    'options' => [
    [
    'status' => 'active', 'text' => 'WHY', 'color' => 'D1F3EC',
    ],
    ]
    ]
    );
    PodioAppField::update($appID, $fieldID, $fieldAttributes);

    Note that this will overwrite the current config - so existing options will be deleted.
    If you want to add a new option you will have to put all existing options with their IDs into the request - eg.:

    $fieldAttributes = array (
    'label' => 'Status',
    'required' => false,
    'settings' => [
    'multiple' => false,
    'options' => [
    [
    id => 1, 'text' => 'Existing option with id=1',
    ],
    [
    id => 2, 'text' => 'New option with id=2',
    ]
    [
    'text' => 'New option - with auto-generated id',
    ]
    ]
    ]
    );
    PodioAppField::update($appID, $fieldID, $fieldAttributes);

    br
    Marek

    2
    Comment actions Permalink
  • Ashwin Malik

    Thank you, Marek!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk