Make select: widget (drop down menu) optional?

I’m trying to implement a drop-down menu of possible slurm constraints to ask for in our RStudio OnDemand app, but I’d like to make it optional. Setting required: false didn’t help. Not every user would want to specify constraints in a job submission, but drop down seems the best option so they can see a list of available options. Is there a null or none option value? If were to add a blank option, how would I handle it in my submit.yml.erb?

form.yml

constraint:
required: false
widget: “select”
label: “Constraint:”
help: Select which constraint you would like to specify from the drop-down.
options:
- [“sha”, “sha”]
- [“wsu”, “wsu”]
- [“sfx”, “sfx”]
- [“hax”, “hax”]
- [“dad”, “dad”]
- [“smt”, “smt”]
- [“rom”, “rom”]
- [“asx”, “asx”]
- [“pcc”, “pcc”]
- [“asx”, “asx”]
- [“intel”, “intel”]
- [“amd”, “amd”]
- [“avx”, “avx”]
- [“avx2”, “avx2”]
- [“highmem”, “highmem”]
id: ‘constraint’

submit.yml.erb

script:
email: <%= ENV[“USER”] %>@xxxx.com
wall_time: <%= (bc_num_hours.blank? ? 1 : bc_num_hours.to_i) * 3600 %>
native:
- “-J”
- “OnDemand:RStudio”
- “-q”
- “<%= qos %>”
- “-N”
- “1”
- “–constraint=<%= constraint %>”
- “-n”
- “<%= cores_number %>”
- “–mem=<%= memory_amount %>G”
- “-t”
- “<%= (bc_num_hours.blank? ? 1 : bc_num_hours.to_i) * 60 %>”

Here’s how you’d check to something empty on the submit.yml.erb. Be careful when trying to copy and paste this because of all the quotation marks that I did not copy & paste correctly.

script:
  email: <%= ENV[“USER”] %>@xxxx.com
  wall_time: <%= (bc_num_hours.blank? ? 1 : bc_num_hours.to_i) * 3600 %>
  native:
    - “-J”
    - “OnDemand:RStudio”
    - “-q”
    - “<%= qos %>”
    - “-N”
    - “1”
   <%- unless contstraint.empty? -%>
   - “–constraint=<%= constraint %>”
   <%- end -%>
   - “-n”
   - “<%= cores_number %>”
   - “–mem=<%= memory_amount %>G”
   - “-t”
   - “<%= (bc_num_hours.blank? ? 1 : bc_num_hours.to_i) * 60 %>”

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.