Dynamic behaviour with check box


Still learning and building on knowledge of ondemand. Such a useful portal for HPC

We are setting up ondemand 2.0.23 and have tried the dynamic behaviour of hiding fields in the form using the select widget (copying from the ansys template) which works great.

Is it possible to show and hide fields using a checkbox widget being checked and unchecked, and if so how should this be constructed in the form.yml.erb?


Hi Kickers. Welcome to the OnDemand Discourse thread.

You ask a great question. Out of the box, we do have what we call “Dynamic JavaScript (DynJS)”. However, it does not currently do what you are asking. The DynJS functionality works in conjunction with the drop-down elements. We do not have anything out of the box for the checkboxes. I would say you should be able to add your own JS functionality in form.yml.erb to control the hide/show functionality.
You should be able to use something like the following at the top of the file.

<script type='text/javascript'>
  Your JS code

Looking forward to seeing how this goes.


Thanks Gerald,

I shall have a play with setting something up using the JS, so I don’t need anything else (or to enable anything else) but to include the JS script at the top of the form.yml.erb?

That should do it. I’ll add a feature request for this functionality. It will be down the road before we can get to it, but it seems that it may be something that we can make function like the Dynamic JS.

Hey @kickers56, were you able to get that working?
I’m pretty new to Open OnDemand, would love to learn how to do it.

@gbyrket In many places I see, batch_connect_session_context identifier prefix used. Is that the default prefix that’s added to get the value of any field in form.yml?

Is there some documentation on how to go about adding this form.js, thanks.

Yes unless you use the id field in the form.yml. Though if you do use id the dynamic javascript we ship with won’t work.

It’s fairly simple - just drop a form.js in the root directory of the app (as a sibling to form.yml and manifest.yml) and it’ll load as a part of the HTML. (you’ll see a lot of examples execute all their functionality when the window is ready)

Here’s an older javascript file from one of our apps, though I can’t find any example we have where we interact with check boxes.

@kickers56 check box functionality is going to be a while because I had to add the feature to the upstream project that builds our forms. So it may be a while before it comes to Open OnDemand.