# Path\_selector widget required true is not working

**URL:** <https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326>\
**Category:** Get Help\
**Created:** [March 5, 2024, 8:20pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326 "2024-03-05T20:20:54Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 5, 2024, 8:20pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/1 "2024-03-05T20:20:55Z")

</div>

I have patch\_selector widget with required true option, but I can submit with empty field w/o choosing a file.

> form:
> 
> - select\_sim\_file

> select\_sim\_file:  
> widget: “path\_selector”  
> required: true  
> required: true  
> directory: “/fs/home”

It’s what I see in the log file  
`App 4003 output: a-option-for-auto-accounts-satellites\"=>false}], [\"medprio_nolim\", \"medprio_nolim\", {\"data-option-for-cluster-amp\"=>false, \"data-option-for-cluster-phoenix\"=>false, \"data-option-for-auto-accounts-flamingo\"=>false, \"data-option-for-auto-accounts-satellites\"=>false}], [\"modelcheck\", \"modelcheck\", {\"data-option-for-cluster-amp\"=>false, \"data-option-for-cluster-phoenix\"=>false, \"data-option-for-auto-accounts-flamingo\"=>false, \"data-option-for-auto-accounts-satellites\"=>false}], [\"test\", \"test\", {\"data-option-for-cluster-amp\"=>false, \"data-option-for-cluster-phoenix\"=>false, \"data-option-for-auto-accounts-flamingo\"=>false, \"data-option-for-auto-accounts-satellites\"=>false}]], :value=>\"test\"}>, #<SmartAttributes::Attributes::BcNumSlots:0x00007f4ca4057ba0 @id=\"bc_num_slots\", @opts={:help=>\"This adds a number that describes the number of processors, CPUs on a single node, or nodes that the submitted job may use\", :value=>\"1\"}>, #<SmartAttributes::Attributes::BcNumHours:0x00007f4ca4057560 @id=\"bc_num_hours\", @opts={:min=>1, :step=>1, :value=>\"1\"}>, #<SmartAttributes::Attribute:0x00007f4ca4056f98 @id=\"select_sim_file\", @opts={:widget=>\"path_selector\", :directory=>\"/fs/home\"}>, #<SmartAttributes::Attribute:0x00007f4ca4056d68 @id=\"select_initial_file\", @opts={:widget=>\"path_selector\", :directory=>\"/fs/cluster/data\", :value=>\"\"}>, #<SmartAttributes::Attribute:0x00007f4ca4056638 @id=\"select_macro_file\", @opts={:widget=>\"path_selector\", :directory=>\"/fs/cluster/data\", :value=>\"\"}>, #<SmartAttributes::Attributes::BcEmailOnStarted:0x00007f4ca4056098 @id=\"bc_email_on_started\", @opts={:value=>\"0\"}>], @app_specific_cache_setting=nil, @errors=#<ActiveModel::Errors:0x00007f4ca1571120 @base=#<BatchConnect::SessionContext:0x00007f4ca45b7c80 ...>, @errors=[]>>, @object_name=\"batch_connect_session_context\", @default_options={}, @default_html_options={}, @multipart=nil, @index=nil>\n\n form.send widget, attrib.id, all_options\n ^^^^^\nDid you mean? text_field):\n 3: \n 4: <%= bootstrap_form_for(@session_context) do |f| %>\n 5: <% f.object.each do |attrib| %>\n 6: <%= create_widget(f, attrib, format: @render_format) %>\n 7: <% end %>\n 8: \n 9: <%- if Configuration.bc_saved_settings? -%>\n \napp/helpers/batch_connect/session_contexts_helper.rb:39:in `create\_widget’\napp/views/batch\_connect/session\_contexts/\_form.html.erb:6\napp/models/batch\_connect/session\_context.rb:43:in `each'\napp/models/batch_connect/session_context.rb:43:in `each’\napp/views/batch\_connect/session\_contexts/\_form.html.erb:5\napp/views/batch\_connect/session\_contexts/\_form.html.erb:4\napp/views/batch\_connect/session\_contexts/new.html.erb:86"`

Any help appreciated.

---

<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:** [March 5, 2024, 9:18pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/2 "2024-03-05T21:18:30Z")

</div>

Sorry for the issue.

Are you saying when you submit without having selected a file or directory, it throws this error?

Does this then take you to the index page of your running apps to login to with some kind of failure for this?

I’m trying to replicate with some apps on my end where I’m setting a `directory` and just hitting launch without the selection but not getting the same result. But maybe that’s the wrong sequence.

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 5, 2024, 9:26pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/3 "2024-03-05T21:26:31Z")

</div>

Sorry if I didn’t explain it clear.

I’m able to submit a job w/o selected file even if I say it’s a required field. So it’s working, but it shouldn’t be.

I’m not sure if log message is relevant, but I thought I will post it here just in case, because usually ppl ask for the log anyway.

I hope it makes sense.

---

<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:** [March 5, 2024, 10:13pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/4 "2024-03-05T22:13:28Z")

</div>

Thanks for the clarification. I’m running this on OOD `3.1.0` currently and not able to get the same behavior. Instead I hit an error around the `working_dir` not being set for the app.

What version of OOD are you running?

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 5, 2024, 10:28pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/5 "2024-03-05T22:28:01Z")

</div>

OnDemand version: 3.1.1

---

<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:** [March 5, 2024, 10:39pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/6 "2024-03-05T22:39:23Z")

</div>

Hmm, I just built with `3.1.1` and tried again with no luck.

What happens if you delete the `form.js` file in the app directory, then reload that page and try again?

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 5, 2024, 10:41pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/7 "2024-03-05T22:41:58Z")

</div>

I don’t have for.js I have form.yml.erb and submit.yml.erb

---

<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:** [March 5, 2024, 10:44pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/8 "2024-03-05T22:44:40Z")

</div>

Thanks for the patience on this. I was hoping another fix would work here.

Could I ask what app you are trying to launch? I’m currently testing with codeserver myself.

Also, what OS are you on?

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 5, 2024, 11:47pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/9 "2024-03-05T23:47:56Z")

</div>

I’m on CentOS 8.

I’m trying to make a submit page to allow users submit jobs from web-interface. Not an interactive app, just simple submit job. Right now I’m testing with Ansys application and I need users to be able to choose their simulation file and it needs to be required field.

Kinda like job composer but w/o direct editing batch script - submitting just by clicking buttons.

I hope it makes sense.

---

<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:** [March 6, 2024, 4:04pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/10 "2024-03-06T16:04:29Z")

</div>

Ahh, ok. Yeah that’s more involved than what I had thought.

So the idea is you are using the `batch_connect` form to launch the job, but not be interactive. Instead to have the code loaded and run and the output landed somewhere? Is that correct?

If so, you’ll likely need to be checking the `submit.yml.erb` for what’s going wrong currently. Because it’s odd that this will launch and not even trigger `BatchConnect` errors, but that the `submit.yml.erb` has changes now that makes more sense.

Are you able to share the `submit.yml.erb`? This might not be easy to accomplish, but I’m happy to try and help out.

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 6, 2024, 6:59pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/11 "2024-03-06T18:59:20Z")

</div>

There is not much going on right now. I’m just mostly testing fields on the form. I don’t have any problems submitting my job. The problem is that required: true is being ignored for the path\_selector field. I have required true for the job name field and that is working ok. I cannot submit w/o job name:

 ![Screenshot 2024-03-06 at 10.54.24 AM](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/3/3d5234c2c0b715705977286e36c26f9685208944.png)

So it sounds more like a Ondemand bug than anythign else.

This is my submit:

> script:  
> native:
> 
> - “–job-name”
> - “\<%= job\_name %\>”
> - “–ntasks”
> - “\<%= num\_cores %\>”
> 
> \<%-  
> license = if solver == “Ansys - Linear” || solver == “Ansys - Thermal”  
> “mech\_1@slurmdb:1,anshpc@slurmdb:#{num\_cores}”  
> elsif solver == “Ansys - Non-Linear”  
> “meba@slurmdb:1,anshpc@slurmdb:#{num\_cores}”  
> elsif solver == “CFX” || solver == “Fluent”  
> “cfd\_solve\_level1@slurmdb:1,cfd\_solve\_level2@slurmdb:1,cfd\_solve\_level3@slurmdb:1,anshpc@slurmdb:#{num\_cores}”  
> elsif solver == “Star-CCM+”  
> “ccmppower@slurmdb:1”  
> end  
> -%\>
> 
> - “–license”
> - “\<%= license %\>”  
> \<%-  
> chdir = File.dirname(select\_sim\_file)  
> -%\>
> - “–chdir”
> - “\<%= chdir %\>”
> - “–error”
> - “%x.%j.out”
> - “–output”
> - “%x.%j.out”

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 13, 2024, 10:35pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/12 "2024-03-13T22:35:10Z")

</div>

@jeff.ohrstrom just curious if you know if it’s a known bug.

---

<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 14, 2024, 1:48pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/13 "2024-03-14T13:48:04Z")

</div>

Yea it is. It’ll be fixed in 3.0.2, I’ve already patched it, I’m just waiting for other bugs to be fixed before releasing it.

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 14, 2024, 6:43pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/14 "2024-03-14T18:43:20Z")

</div>

@jeff.ohrstrom  
I’m on OnDemand version: 3.1.1 Can I patch it in 3.1.1 ?

Another weird behaivor I see with path selector widget when I make it hidden, it hides the text filed but not the button.

 ![Screenshot from 2024-02-28 11-56-44](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/c/c1f454e98bd0ccb3bdd02463208402c1eabc0682.png)

I reported it here:

> [@Cluster specific modules don't populate in form.yml.erb](https://discourse.openondemand.org/t/cluster-specific-modules-dont-populate-in-form-yml-erb/3287/20):
>
> I cleaned my browse cache and I tried incognito mode and it didn’t help. My OnDemand version: 3.0.3. Is it better in a new version or do you see it in all versions? And I can replicate this issue as well. I have an older version of Ondemand 2.0.32 and I see path selector error there: #\<ActionView::Template::Error: undefined method `path\_selector’ for #BootstrapForm::FormBuilder:0x00007f2d18de7c58\> Was path selector only intorduced recently?

---

<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 14, 2024, 7:13pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/15 "2024-03-14T19:13:32Z")

</div>

> [@ssofya](#):
>
> I’m on OnDemand version: 3.1.1 Can I patch it in 3.1.1 ?

Sure, just take a backup of the original files so you can fix it if things go south, which they may. Editing the html files may not cause disruptions - but editing the actual `.rb` files may have unexpected consequences to the people who have active PUNs with the old files. So while you’re doing the work - I’d suggest you put OOD in maintenance mode or similar and restart everyone’s PUNs afterwards.

Here is the patch. You don’t need the test case update, just the updates in the other 2 files.

> <https://github.com/OSC/ondemand/pull/3399/files>
>
> Backport #3375 to 3.1 to allow the path\_selector to redefine html options like l…abel and help message.

> [@ssofya](#):
>
> Another weird behaivor I see with path selector widget when I make it hidden, it hides the text filed but not the button.

I just filed a bug for that. I’ll see what I can do for the 3.1 release cycle.

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 14, 2024, 9:33pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/16 "2024-03-14T21:33:51Z")

</div>

I got an error on the web-page:

```auto
#<NameError: undefined local variable or method `options' for #<ActionView::Base:0x00000000021368>
Did you mean? url_options>

```

 ![Screenshot from 2024-03-14 14-32-42](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/2/2dc4551589d11cb9fec411f4ccd8fca4e8867483.png)

I can revert back, but I’m curious if you know what is wrong

---

<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 15, 2024, 1:46pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/17 "2024-03-15T13:46:27Z")

</div>

You’re using `options` on line 15, but you have to define them on line 12.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/f/fb6150318534e6960805e7a14568db2a94ce8ae0.png)

---

<div class="post-metadata">

**Author:** ![ssofya](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ssofya/32/1145_2.png) [@ssofya](https://discourse.openondemand.org/u/ssofya)\
**Post date:** [March 15, 2024, 7:22pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/18 "2024-03-15T19:22:24Z")

</div>

My bad works like charm

---

<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 11, 2024, 7:22pm UTC](https://discourse.openondemand.org/t/path-selector-widget-required-true-is-not-working/3326/19 "2024-09-11T19:22:25Z")

</div>

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