# Dynamic Behavior - Issue

**URL:** <https://discourse.openondemand.org/t/dynamic-behavior-issue/1966>\
**Category:** Get Help\
**Tags:** ondemand2, question\
**Created:** [March 18, 2022, 1:49am UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966 "2022-03-18T01:49:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chidcrushev](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/chidcrushev/32/1010_2.png) [@chidcrushev](https://discourse.openondemand.org/u/chidcrushev)\
**Post date:** [March 18, 2022, 1:49am UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/1 "2022-03-18T01:49:39Z")

</div>

Hello team,

I’ve been trying to hide a form field element based on the value of a select dropdown form field

Reference → [Apps Development - Dynamic Behavior](https://osc.github.io/ood-documentation/develop/how-tos/app-development/dynamic-apps.html)

The issue is, if I add multiple data-hide(Want to hide two form fields - **version,interface** ) for the select dropdown( **settings** ) with **standard** option, it doesn’t seem to work. Please refer the below code block.

**form.yml.erb**

```auto
<%-
require 'open3'
begin
    # Command to Run
    script = 'sinfo -h --format="%P"'
    # Create a partitions array to dynamically populate the queues associated with the user
    partitions = []
    # Store the output, error, status
    output, status = Open3.capture2('bash', stdin_data: script)
    # puts status
    if status.success?
        # Add it to the custom_envs array by splitting the output at '\n'. 
        output.split("\n").each do |queue|
            if queue != 'backfill'
                queue = queue.gsub("*", "")
                partitions.push(queue)
            end
        end
        puts partitions
    else
        partition_error = "Error"
    end
rescue => e
    partition_error = e.message.strip
end
-%>

---
cluster: "discovery"
form:
  - custom_queue
  - bc_num_hours
  - bc_num_slots
  - num_cpus
  - num_mem
  - num_gpus
  - email
  - working_dir
  - settings
  - version
  - interface

submit: submit.yml.erb
id: submitForm
name : submitForm
title: Jupyter Lab/NoteBook
attributes:
  custom_queue:
    id: custom_queue
    label: Partition
    widget: select
    cacheable: false
    help: |
      - [Partition Documentation](https://hpc.nmsu.edu/discovery/home/partitions/)
    <%- if partition_error || partitions.blank?-%>   
      <div class="text-danger">Error while fetching Partition. Please contact support!</div>
    <%- else -%>
    options:
    <%- partitions.each do |q| -%>
      - ["<%= q %>", "<%= q %>"]
    <%- end -%>
    <%- end -%>
  bc_num_hours:
    id: bc_num_hours
    label: Walltime (Hours)
    help: |
      - Number of hours to allocate
      - Exceeding walltime time will automaticaly stop this job.
    cacheable: false
    widget: number_field
    max: 24
    min: 1
    step: 1
    value: 1
  bc_num_slots: 1
  num_cpus:
    id: num_cpus
    label: CPUs (Threads)
    help: Number of CPU threads
    cacheable: false
    widget: number_field
    max: 16
    min: 2
    step: 2
    value: 2
  num_mem:
    id: num_mem
    label: Memory (GB/Gigabytes)
    help: Total memory is available to all assigned threads!
    cacheable: false
    widget: number_field
    max: 64
    min: 1
    step: 1
    value: 2
  num_gpus:
    id: num_gpus
    label: "GPUs"
    help: "Number of GPU or Cuda devices"
    cacheable: false
    widget: number_field
    max: 2
    min: 0
    step: 1
    value: 0
  email:
    id: email
    label: Email Address
    help: |
      Enter your email address if you would like to receive job notifications (start, finished, failed, etc..). Otherwise, leave the field empty.

      --------------------------
    cacheable: true
    widget: text_field
  working_dir:
    id: working_dir
    label: Jupyter Working Directory
    help: |
      - Select your jupyter project directory
      - The default is your home directory ($HOME) when left empty."
    cacheable: false
    data-filepicker: true
    data-target-file-type: dirs # Valid values are: files, dirs, or both
    readonly: true
  settings:
    id: settings
    label: Advanced Submission Settings
    help : | 
      Select Anaconda Version, Jupyter Server Type, Setup Commands
    cacheable: false
    widget: select
    options:
      - [
          'standard', 'standard',
          data-hide-version: true,
          data-hide-interface: true
        ]
      - ['advanced', 'advanced']
  version:
    id: version
    label: Anaconda Version
    help: |
      - Anaconda3 is based on Python 3.x
      - Anaconda2 is based on Python 2.x
      - Miniforge is based on Python 3.x, conda-forge & Mamba
    cacheable: false
    widget: select
    options:
      - ["Anaconda3", "anaconda"]
      - ["Anaconda2", "anaconda2"]
      - ["Miniforge", "miniforge"]
  interface:
    id: interface
    label: "User Interface"
    help: |
      - Select which user interface you want
      - New = Jupyter Lab
      - Old = Jupyter NoteBook
    cacheable: false
    widget: select
    options:
      - ["Jupyter Lab", "lab"]
      - ["Jupyter Notebook", "notebook"]

```

Also, I tried data-hide with the **checkbox** element. It doesn’t seem to work. Does this behavior only supports select element?

I highly appreciate any help on this. Please let me know if you need any additional information. Thanks in advance!!

---

<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:** [March 18, 2022, 1:35pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/2 "2022-03-18T13:35:05Z")

</div>

> [@chidcrushev](#):
>
> ```auto
> num_gpus:
> id: num_gpus
> 
> ```

You cannot use this feature while setting the `id` property. Remove all your `id`s and it should start to work.

---

<div class="post-metadata">

**Author:** ![chidcrushev](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/chidcrushev/32/1010_2.png) [@chidcrushev](https://discourse.openondemand.org/u/chidcrushev)\
**Post date:** [March 18, 2022, 3:41pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/3 "2022-03-18T15:41:46Z")

</div>

Hey Jeff,

Thanks for fast response. I removed all the id’s and below is my updated code.

**form.yml.erb**

```auto
<%-
require 'open3'
begin
    # Command to Run
    script = 'sinfo -h --format="%P"'
    # Create a partitions array to dynamically populate the queues associated with the user
    partitions = []
    # Store the output, error, status
    output, status = Open3.capture2('bash', stdin_data: script)
    # puts status
    if status.success?
        # Add it to the custom_envs array by splitting the output at '\n'. 
        output.split("\n").each do |queue|
            if queue != 'backfill'
                queue = queue.gsub("*", "")
                partitions.push(queue)
            end
        end
        puts partitions
    else
        partition_error = "Error"
    end
rescue => e
    partition_error = e.message.strip
end
-%>

---
cluster: "discovery"
form:
  - custom_queue
  - bc_num_hours
  - bc_num_slots
  - num_cpus
  - num_mem
  - num_gpus
  - email
  - working_dir
  - settings
  - version
  - interface

submit: submit.yml.erb
name : submitForm
title: Jupyter Lab/NoteBook
attributes:
  custom_queue:
    label: Partition
    widget: select
    cacheable: false
    help: |
      - [Partition Documentation](https://hpc.nmsu.edu/discovery/home/partitions/)
    <%- if partition_error || partitions.blank?-%>   
      <div class="text-danger">Error while fetching Partition. Please contact support!</div>
    <%- else -%>
    options:
    <%- partitions.each do |q| -%>
      - ["<%= q %>", "<%= q %>"]
    <%- end -%>
    <%- end -%>
  bc_num_hours:
    label: Walltime (Hours)
    help: |
      - Number of hours to allocate
      - Exceeding walltime time will automaticaly stop this job.
    cacheable: false
    widget: number_field
    max: 24
    min: 1
    step: 1
    value: 1
  bc_num_slots: 1
  num_cpus:
    label: CPUs (Threads)
    help: Number of CPU threads
    cacheable: false
    widget: number_field
    max: 16
    min: 2
    step: 2
    value: 2
  num_mem:
    label: Memory (GB/Gigabytes)
    help: Total memory is available to all assigned threads!
    cacheable: false
    widget: number_field
    max: 64
    min: 1
    step: 1
    value: 2
  num_gpus:
    label: "GPUs"
    help: "Number of GPU or Cuda devices"
    cacheable: false
    widget: number_field
    max: 2
    min: 0
    step: 1
    value: 0
  email:
    label: Email Address
    help: |
      Enter your email address if you would like to receive job notifications (start, finished, failed, etc..). Otherwise, leave the field empty.

      --------------------------
    cacheable: true
    widget: text_field
  working_dir:
    label: Jupyter Working Directory
    help: |
      - Select your jupyter project directory
      - The default is your home directory ($HOME) when left empty."
    cacheable: false
    data-filepicker: true
    data-target-file-type: dirs # Valid values are: files, dirs, or both
    readonly: true
  settings:
    label: Advanced Submission Settings
    help : | 
      Select Anaconda Version, Jupyter Server Type, Setup Commands
    cacheable: false
    widget: select
    options: 
      - ["standard", "standard", 
        data-hide-version: true,
        data-hide-interface: true,
      ]
      - ["advanced", "advanced"]
  version:
    label: Anaconda Version
    help: |
      - Anaconda3 is based on Python 3.x
      - Anaconda2 is based on Python 2.x
      - Miniforge is based on Python 3.x, conda-forge & Mamba
    cacheable: false
    widget: select
    options:
      - ["Anaconda3", "anaconda"]
      - ["Anaconda2", "anaconda2"]
      - ["Miniforge", "miniforge"]
  interface:
    label: "User Interface"
    help: |
      - Select which user interface you want
      - New = Jupyter Lab
      - Old = Jupyter NoteBook
    cacheable: false
    widget: select
    options:
      - ["Jupyter Lab", "lab"]
      - ["Jupyter Notebook", "notebook"]

```

Now, the **interface** field gets hidden on initial page load. However, on toggling between the select dropdown( **settings** ) selection, the behavior stops working as well. Also, the **version** form field never gets hidden.

Any suggestions on how we can fix this?

Thanks for your time and consideration.

---

<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:** [March 18, 2022, 4:53pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/4 "2022-03-18T16:53:26Z")

</div>

One million apologies. Apparently, we never promoted `2.0.22` which has this bugfix (I’m guessing you’re on 20). I was going to promote `2.0.24` next week - but I’ll redouble my efforts on confirming it and get that pushed out today for you.

---

<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:** [March 18, 2022, 8:23pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/5 "2022-03-18T20:23:41Z")

</div>

@chidcrushev `2.0.23` is now publicly available. It has the bugfix for this issue.

---

<div class="post-metadata">

**Author:** ![chidcrushev](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/chidcrushev/32/1010_2.png) [@chidcrushev](https://discourse.openondemand.org/u/chidcrushev)\
**Post date:** [March 21, 2022, 5:19pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/6 "2022-03-21T17:19:50Z")

</div>

@jeff.ohrstrom Thank you so much. We are on 2.0.20 and I will let you know after upgrading ours to 2.0.23 to see whether we got it working.

---

<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:** [September 17, 2022, 5:20pm UTC](https://discourse.openondemand.org/t/dynamic-behavior-issue/1966/7 "2022-09-17T17:20:06Z")

</div>

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