theexiile1305
New Creator

Update CMS_INPUT_LIST through FS API

Jump to solution

Good day,

First of all, a short preface that I have only recently started developing via FS API.

In a template there is a CMS_INPUT_LIST myFancyInputList with several ENTRY and I would like to retrieve the values of this InputList via FS API.

I could already figure out how to set the values?

formData.form.findEditor(“myFancyInputList”)
            .let { it as OptionFactoryProvider }
            .optionFactory.create(person.tenant)
            .let { hashSetOf(it) }
            .let { formData.get(null, “myFancyInputList”).set(it) }

But how do I get the already set values so that I can perform an update?

Many thanks in advance and best regards,
theexiile1305

0 Kudos
1 Solution

Accepted Solutions
mbergmann
Crownpeak employee

Hi, 

concerning setting the value: no need for that complicated way via OptionProvider. You can directly use a Set of „compatible“ objects in the FormField.set(…) call. Which type is compatible depends on the definition of the INPUT_LIST: If it’s based on simple <ENTRY>s, you can use a Set of Strings, for database based entries (INCLUDE_OPTIONS type="database") a Set of entities or also a Set of Datasets etc.

You get the values also via the FormField‘s get() method which will return a Set<Option> with Option just being a kind of „container“ for the real values - just use .getValue() on each entry. 

The type of the returned object via that call (again) depends on the way the INPUT_LIST is configured.

Hope this helps.

By the way: Things like these are part of our „Developer Training Advanced“ - you can find upcoming planned schedules here - there is an English course planned in January 😉

Michael

View solution in original post

0 Kudos
1 Reply
mbergmann
Crownpeak employee

Hi, 

concerning setting the value: no need for that complicated way via OptionProvider. You can directly use a Set of „compatible“ objects in the FormField.set(…) call. Which type is compatible depends on the definition of the INPUT_LIST: If it’s based on simple <ENTRY>s, you can use a Set of Strings, for database based entries (INCLUDE_OPTIONS type="database") a Set of entities or also a Set of Datasets etc.

You get the values also via the FormField‘s get() method which will return a Set<Option> with Option just being a kind of „container“ for the real values - just use .getValue() on each entry. 

The type of the returned object via that call (again) depends on the way the INPUT_LIST is configured.

Hope this helps.

By the way: Things like these are part of our „Developer Training Advanced“ - you can find upcoming planned schedules here - there is an English course planned in January 😉

Michael

0 Kudos