Multi-select

Matt's Avatar

Matt

22 Aug, 2016 09:53 PM

How would I set multiple values for a multi-select? The value I'm entering into the dynamicField 'healthsciences' is actual an array from a multi-select input $user_data['healthsciences'].

  $data = array(
                  'name' => $name,
                  'parentFolderId' => '9e92f2100a92bba37b7a93f0b0424729',
                  'metadataSetPath' => '/In the news',
                  //'parentFolderId' => $folderId,
                  'linkURL' => $user_data['link'],
                  'siteId' => '3b6fddc09b64773a0091cdb1407b7f34',
                  'shouldBePublished' => true,
                  'shouldBeIndexed' => false,
                  'metadata' => array(
                      'title' => $user_data['title'],
                      'keywords' => '',
                      'endDate' => $startDate,
                      'startDate' => $startDate,
                      'summary' => $user_data['summary'],
                      'dynamicFields' => array(
                          'dynamicField' => array(
                              array('name' => 'newspaper', 'fieldValues' => array('fieldValue' => array('value' => $user_data['newspaper']))),
                              array('name' => 'newwindow', 'fieldValues' => array('fieldValue' => array('value' => $user_data['newwindow']))),
                              array('name' => 'healthsciences', 'fieldValues' => array('fieldValue' => array('value' => $user_data['healthsciences']))),
                              array('name' => 'tags', 'fieldValues' => array('fieldValue' => array('value' => $user_data['tags']))),
                              array('name' => 'news-category', 'fieldValues' => array('fieldValue' => array('value' => $user_data['newscategory']))),
                              array('name' => 'unid', 'fieldValues' => array('fieldValue' => array('value' => $user_data['unids'])))

                          )
                        )
                      )
                    );

  1. 1 Posted by Wing Ming Chan on 23 Aug, 2016 10:10 PM

    Wing Ming Chan's Avatar

    Hi Matt,

    If you want to use my library, then it will require only a few lines of code to solve your problem. Of course you have to learn how to use it first.

    If you want to struggle with your own code, you may still want to look at the source code of my library. It is very likely that you can find answers for most of your questions.

    Wing

  2. 2 Posted by Ryan Griffith on 24 Aug, 2016 03:40 PM

    Ryan Griffith's Avatar

    Hi Matt,

    It looks like you are very close, but need to wrap the value array within your fieldValue array one more time. Specifically, fieldValue is an array of arrays containing the information for each individual value. For example:

    $data = array( 
      ... 
      'metadata' => array( 
        ...
        'dynamicFields' => array( 
          'dynamicField' => array( 
            ...
            array(
              'name' => 'healthsciences', 
              'fieldValues' => array(
                'fieldValue' => array(
                  array('value' => $user_data['healthsciences'])
                )
              )
            ), 
            ...
          )
        )
      )
    );
    

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by Matt on 24 Aug, 2016 05:06 PM

    Matt's Avatar

    That did it. Thanks!

  4. 4 Posted by Ryan Griffith on 24 Aug, 2016 07:20 PM

    Ryan Griffith's Avatar

    Not a problem at all, Matt. I am glad to hear the proposed change did the trick.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  5. Ryan Griffith closed this discussion on 24 Aug, 2016 07:20 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM