I have a variable in a form that has the widget set to hidden_field. It works to set a default value on the field attributes. I want to be able to set the variable from another variable with the data-set option. This is what I have in the form but the variable is not changing as the Account variable changes.
account:
label: “Account”
widget: select
options:
<%- CustomAccounts.Accounts.each do |a| -%>
- [ “<%= a %>”, “<%= a %>”,
data-max-num-cores: “<%= CustomCores.Cores[a] %>”,
data-max-num-nodes: “<%= CustomNodes.Nodes[a] %>”,
data-max-gpus: “<%= CustomGpus.Gpus[a] %>”,
data-set-ntype: “<%= CustomNtype.Ntype[a] %>”
]
<%- end -%>
What you expect is what should happen. Indeed we even do the same in a few of our apps.
I’ll have to check into it and try to replicate. Off the top - your YAML (and the data attributes) looks OK so I’m really not sure why this would be the case.
This leads me to believe it’s something very simple that we’re overlooking - did you happen to set the id for any of these fields? Specifying the id can throw dynamic behavior off. I guess I’d also ask if you have any form.js that could conflict with this.
I am unable to replicate the issue. I had to modify the form slightly to accommodate for CustomAccounts.Accounts., but it appears to work as you’d expect (it correctly sets the hidden field ntype.
What browser are you using? Also what version of OnDemand are you on? (I tested on 3.0.3).
This is what i edited it, though I don’t think it’s any different than what you’ve provided. I specified the accounts in the same way that you’ve got them in the option output there.
That said - maybe there’s some 3rd account that’s throwing this off when you select it. I could not replicate with these 2 accounts - gctest and open. Perhaps there’s a 3rd that I’m missing that’s the key to this issue…
I am using firefox and we are on version 2.0.32 of OpenOndemand. There isn’t a 3rd account on my user just those two. Your version is basically the same as mine as far as I can see.
Maybe it is working. I made the variable just a text field and it changes. But I don’t see any change in the value of the variable in the html source. I’ll see if it works to control another variable that I need it for.
Yeah when I select the gctest account the ntype variable gets set to gpu but the node_type variable isn’t getting set with the data-option-for-ntype-gpu:
Ok I am trying this on my test server with OpenOndemand 3.0.3. The bc_dynamic_js is set to true. When I select the open account the rc_partition and node_type is set correctly but when I switch to the gctest account they do not change. I’ve verified the nodetype variable is set to gpu. I’ve included the form.yml.erb as form.txt. It seems that whichever account I have first in the account options that is what is setting the other two select fields. form.txt (4.9 KB)
I have found that if I manually change the nodetype variable then go and set the account to the type of node for that node type it works but only for that account/nodetype pair.
I’ve found a different way of going about doing what I needed that mostly works with 2.0.23 by using a case statement where I select the account to set values and hide fields.