Update CMS_INPUT_LIST through FS API
Author: theexiile1305
Publication Date: 12/3/2024 9:16
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
-
Author: mbergmann - 12/4/2024 20:49
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
Please sign in to leave a comment.
Comments
1 comment