# Make select: widget (drop down menu) optional?

**URL:** <https://discourse.openondemand.org/t/make-select-widget-drop-down-menu-optional/2033>\
**Category:** Get Help\
**Tags:** ondemand2, question\
**Created:** [April 28, 2022, 5:31pm UTC](https://discourse.openondemand.org/t/make-select-widget-drop-down-menu-optional/2033 "2022-04-28T17:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabdall33](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/sabdall33/32/1065_2.png) [@sabdall33](https://discourse.openondemand.org/u/sabdall33)\
**Post date:** [April 28, 2022, 5:31pm UTC](https://discourse.openondemand.org/t/make-select-widget-drop-down-menu-optional/2033/1 "2022-04-28T17:31:09Z")

</div>

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 %\>”

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [April 28, 2022, 8:17pm UTC](https://discourse.openondemand.org/t/make-select-widget-drop-down-menu-optional/2033/2 "2022-04-28T20:17:50Z")

</div>

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.

```ruby
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 %>”

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [October 25, 2022, 8:18pm UTC](https://discourse.openondemand.org/t/make-select-widget-drop-down-menu-optional/2033/3 "2022-10-25T20:18:48Z")

</div>

Closed on October 25, 2022, 8:18pm UTC

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