Problems with multiple selection drop down box


I’m new to OOD so forgive me if this is a simple fix…

I’m editing a form which creates a JupyterHub instance on our cluster to allow a user to select additional modules they would like to load into their environment. I am trying to do this using a multiple select box. I can get the multiple select box to show on the form and it does indeed allow multiple selections but when I launch the instance the data does not seem to pass through.

I have the following attribute in my form.yml.erb:

    widget: select
    label: Extra Python 3.7.4 Modules
    help: Select additional Python 3.7.4 modules you wish to include
      multiple: "true"
      size: 5
      - [ "TensorFlow 2.0.0", "TensorFlow/2.0.0-foss-2019b-Python-3.7.4" ]
      - [ "scikit-learn 0.21.3", "scikit-learn/0.21.3-foss-2019b-Python-3.7.4" ]

(the options are actually generated from a text file but I’ve included hard-coded examples to make it simpler)

Now, when I launch the instance I can see in the staged directory within user_defined_context.json that extra_py374_modules: "". I would expect this to be an array of all of my selections. When I remove the html_options from my attribute (making it a single select rather than multiple select), the context gets a string containing the module I chose e.g. extra_py374_modules: "TensorFlow/2.0.0-foss-2019b-Python-3.7.4".

The result of this problem means no extra modules get loaded.

What am I doing wrong?

Kind regards,

Hi and welcome!

I did some digging this morning, and unfortunately I don’t think we support array parameters, only scalars. So while the array being passed, it’s not being permitted through.

I think in the interim you could try check boxes for each module you want to load, which is not optimal because you’ll have an option for each module, but still gives your users some amount of options.

Okay, thanks for the information.

Is it possible for me to make the widget behave so that instead of passing an array it passes a scalar which may be a comma-separated or space-separated collection of all the selections made? (I’m mainly pursuing this avenue over checkboxes because it may be possible that the user could have 50+ extra modules to choose from)

Hey! Sorry for the delayed response. I guess I read it and then immediately forgot.

Yes, passing a string that is actually a space separated list is trivial like so:

    widget: select
    label: Rick and Morty Characters
      multiple: "true"
      size: 5
      - [ "A story characters", "rick morty summer c137" ]
      - [ "B story characters", "jerry betch squanchy c137" ]

Again, sorry for the delay, let us know if you have any other questions.