# Issues with Dynamic Form

**URL:** <https://discourse.openondemand.org/t/issues-with-dynamic-form/3663>\
**Category:** Get Help\
**Created:** [July 30, 2024, 6:11pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663 "2024-07-30T18:11:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![karcaw](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/karcaw/32/745_2.png) [@karcaw](https://discourse.openondemand.org/u/karcaw)\
**Post date:** [July 30, 2024, 6:11pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/1 "2024-07-30T18:11:20Z")

</div>

I am having issues getting my dynamic forms working to hide select options. I have proven that the dynamic forms are enabled, as the dynamic\_forms.js is included, and I can use the `data-set-<id>` works ok. Is there any way to turn on some debugging on what is going on in the dynamic forms?

In looking into this I cloned the `git@github.com:OSC/bc_osc_jupyter.git` repository into my dev directory and then did a command line to switch out ascend to boreal(my cluster name):  
`grep -r -l ascend | while read i; do sed -i -e 's/ascend/boreal/' $i;done`  
and then loaded it up, the form still has all the options in the Node type selector.

Any thoughts on what I can do to enable the hisign of selections? or debug the issue at a java-script level?

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [July 30, 2024, 6:30pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/2 "2024-07-30T18:30:11Z")

</div>

I’d recommend using an editor and not `sed` when making changes, because now we both don’t know what’s in that `form` and working off a `sed` command is needlessly complicated.

There’s no debugging bit to switch on for dynamic forms.

My guess is you just need to tinker some, use an editor to do this. For JS the way to debug would be the usual `F12` then use the dev console to log any statements and see what’s going on. But, without an actual config file to look at it’s very hard to debug or guess at what is wrong.

---

<div class="post-metadata">

**Author:** ![karcaw](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/karcaw/32/745_2.png) [@karcaw](https://discourse.openondemand.org/u/karcaw)\
**Post date:** [July 31, 2024, 5:31pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/3 "2024-07-31T17:31:27Z")

</div>

> [@travert](#):
>
> I’d recommend using an editor and not `sed` when making changes, because now we both don’t know what’s in that `form` and working off a `sed` command is needlessly complicated.

sed is an editor by definition, it is a `stream editor for filtering and transforming text` (from the man page). And I was very specific to give the formula for getting the exact code for the form. You clone to Git repo, and run a simple command. the bash command around sed is more complicated than the simple substitution done by sed. If it helps, you can goto [github.com](http://github.com):OSC/bc\_osc\_jupyter.git and just assume I am on the ascend cluster.

> [@travert](#):
>
> There’s no debugging bit to switch on for dynamic forms.

Acknowledged.

> [@travert](#):
>
> My guess is you just need to tinker some, use an editor to do this. For JS the way to debug would be the usual `F12` then use the dev console to log any statements and see what’s going on. But, without an actual config file to look at it’s very hard to debug or guess at what is wrong.

First of all, F12 runs System Preferences on my Mac and locks the screen on my Linux box, so Windows-based Function keys won’t help.

Second, this is what I had been doing for the two days before I asked the question, I was more hoping for information on how what to be looking at, and maybe how to debug it better.

---

<div class="post-metadata">

**Author:** ![karcaw](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/karcaw/32/745_2.png) [@karcaw](https://discourse.openondemand.org/u/karcaw)\
**Post date:** [October 4, 2024, 11:18pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/4 "2024-10-04T23:18:21Z")

</div>

I found that reverting this change in the code makes dynamic forms work properly on a single-cluster config with cluster-based dynamic forms:

> <https://github.com/OSC/ondemand/pull/1812/files#r798918283>
>
> This fixes a bug where invalid apps run into this stack trace 
> 
> !\[image\](https:/…/user-images.githubusercontent.com/4874123/152417766-8a55ad6f-121b-48e6-9300-43757551bacd.png)
> 
> Here's the same in text.
> 
> \`\`\`text
> undefined method \`map' for "clusterfirst\_item":String Did you mean? tap 
> 
> app/models/batch\_connect/app.rb:192:in \`build\_session\_context'
> app/controllers/batch\_connect/session\_contexts\_controller.rb:67:in \`set\_session\_context'
> app/controllers/batch\_connect/session\_contexts\_controller.rb:8:in \`new'
> actionpack (6.0.4.1) lib/action\_controller/metal/basic\_implicit\_render.rb:6:in \`send\_action'
> \`\`\`
> 
> To replicate you just make an app who's form element in your \`form.yml\` that isn't an array.
> 
> \`\`\`yaml
> form:
> this\_should\_be\_a\_string
> \`\`\`
> 
> Indeed I even made the mistake myself in this app
> 
> https://github.com/OSC/ondemand/blob/62f755763cbee89d3a838d15dc523d640b83d065/apps/dashboard/test/fixtures/usr/shared/bc\_app/form.yml
> 
> 
> 
> ┆Issue is synchronized with this \[Asana task\](https://app.asana.com/0/1201735133575781/1201767682109273) by \[Unito\](https://www.unito.io)

@jeff.ohrstrom any comments on why it needs to be a fixed value?

---

<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:** [October 8, 2024, 3:55pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/5 "2024-10-08T15:55:50Z")

</div>

I put in the ticket why I believe it needs to be a fixed value.

As a work around, you can specify `cluster` in the `form` instead of outside of it. The code will recognzie there’s a `cluster` attribute and not create the fixed attribute instead using the one you’ve supplied.

Here’s an example of how to do this that I hacked around on and got it working.

```yaml
form:
  - queue
  - cluster
attributes:
  cluster:
    widget: hidden_field
    value: owens
  queue:
    widget: 'select'
    options:
     - ["oakley queue", data-option-for-cluster-owens: false]
     - ["owens queue", data-option-for-cluster-oakley: false]

```

---

<div class="post-metadata">

**Author:** ![mjbludwig](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/mjbludwig/32/684_2.png) [@mjbludwig](https://discourse.openondemand.org/u/mjbludwig)\
**Post date:** [October 15, 2024, 6:43pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/6 "2024-10-15T18:43:26Z")

</div>

I do something similar for a Jupyter app that uses the linux host-based adapter to submit to some big file servers outside of slurm, but I just do the following like its a normal form field:

```auto
attributes:
....
  cluster:
    widget: "select"
    label: "File Server to use"
    help: "Select which fileserver you want to run on"
    options:
      - ["File server 1", "Fileserver1"]
      - ["File server 2", "Fileserver2"]
...

```

I then have cluster.d configs for each file server.

---

<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:** [April 13, 2025, 6:43pm UTC](https://discourse.openondemand.org/t/issues-with-dynamic-form/3663/7 "2025-04-13T18:43:45Z")

</div>

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