Karsten
I'm new here

Scripting: How to enable input compontent which is not editable by rules

Editors should only change the value of a CMS_INPU_LIST via  a script rather than directly in the form. So I made this input not editable via rules. How can I make it editable via script to set the new values? I get the input field via the FS_BUTTON

thanks

// ??? make editable here

targets_inputlist_from_button.set(mappedTargetsNew); // set value here

// ??? make not editable here

<FS_BUTTON

          name="fs_targetbutton"

          hFill="no"

          noBreak="no"

          onClick="script:news_target_picker"

          style="button"

          useLanguages="no">

          <LANGINFOS>

            <LANGINFO lang="*" label="Set news targets" description="TEXT"/>

            <LANGINFO lang="DE" label="Nachrichtenziele zuweisen" description="TEXT"/>

          </LANGINFOS>

          <PARAMS>

            <PARAM name="targets_inputlist_from_button">#field.cs_targetmapping</PARAM>

            <PARAM name="editor_input_from_button">#field.cs_autor</PARAM>

          </PARAMS>

        </FS_BUTTON>

0 Kudos
12 Replies
Peter_Jodeleit
Crownpeak employee

Why don't you use a CMS_INPUT_CHECKBOX for this? Look into the rules demo project for inspirations..

Peter
0 Kudos

No! I need to do it this way and I need to know the code to make this CMS_INPUT_LIST editable from within my script please.

0 Kudos

Perhaps combine a CMS_INPUT_TOGGLE switched from the FS_BUTTON and a rule depending on the TOGGLE...

Peter
0 Kudos

Do you want to make the list editable for editors to change it or simply set its value from within the script?

Cheers,

Stefan

0 Kudos

Hi,

the list is changed by the script I run with the button. Nevertheless the editor should be able to see the mapped values but not to change them directly.

list1.jpg

I tried a second list which maps on the same column just to show the selected values but on save these values overwrite the new selections made via the button. And the system warned that a field is mapped twice which can cause this behaviour. so I need a way around this issue.  Thanks

0 Kudos

Well, simply set the value to the list field via script then. Why do you want to enable the UI?

0 Kudos

because otherwhise i get an exception that the field is not editable.

if(formData != null) {

        datasetFormData = element.getFormData();

       

        //get selected gui value

        selectedValuesNew = formData.get(null,"cs_target").get(); //set

       

        // Update selected targets

        Set<Option> mappedTargetsNew = new HashSet<Option>();

        for(value:selectedValuesNew){

                mappedTargetsNew.add(optionModel.getOption(value.toString()));

        }

       

        // Insert previously selected hidden options (Editor has not right to alter all options but they must be kept)

        mappedTargetsNew.addAll(hiddenMappedTargets);

       

        // Update element in the form   

        targets_inputlist_from_button.set(mappedTargetsNew);

               

    }

0 Kudos

What version are we talking about?

Please, post or attach the exception or report it to the help desk. Rule-based disabling is not meant to disable API use.

Cheers,

Stefan

0 Kudos

Maybe there is another possibility to show the mapped datasets in the form instead of using this list?

0 Kudos