New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using optgroup's (or possibility to disable fields) on "select" widgets in form.yml for apps #2762
Comments
Hi, thanks for the ticket. Yea this seems interesting. I'll look into how to disable certain fields. |
I thought a bit about how one could possible express the optgroups in yaml (which look like this https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup ) Maybe some form of extra tag version:
widget: "select"
label: "Runtime"
options:
- ['foo', 'foo']
- ['baz', 'baz', group: 'User supplied']
- ['bar', 'bar', group: 'User supplied'] or as a nested/dict type yaml version:
widget: "select"
label: "Runtime"
options:
- ['foo', 'foo']
- User supplied:
- ['baz', 'baz']
- ['bar', 'bar'] yaml feels a bit precarious here though, i'm not sure what's actually valid syntax (but i think this would both be OK technically) |
Any progress on this? |
No, not yet unfortunately. |
After playing around with the "data-option-for-xxx" stuff I realized this might just already work.
produces the HTML <option disabled="disabled" value="x">this is a separator</option> and I think all browsers just ignore the I did find a strange thing though; if I leave the value field empty
then an extra field is added <option disabled="disabled" selected="selected" value="">this is a separator</option> which forcibly selects this disabled field by default when you reload the browser due to the (though this isn't as nice as the optgroup) |
While working on something different - I accidentally discovered how to make this work. We're always passing in Arrays to the attributes:
opt_group_test:
widget: select
options:
'first_group':
- 'first_group_option'
'second_group':
- 'second_group_option' |
I can confirm that this works already! Great, you can even use spaces in the group name. I've put it to use in our deployment now attributes:
...
version:
options:
System provided:
<% glob_prettify_lookup(["/apps/portal/rstudio/*.sh"]).each do |pretty_path, path| %>
- [ "<%= pretty_path %>", "<%= path %>" ]
<% end %>
User provided:
- [ "~/portal/rstudio/*.sh", "x", disabled: true ]
<% glob_prettify_lookup(["#{Dir.home}/portal/rstudio/*.sh"]).each do |pretty_path, path| %>
- [ "<%= pretty_path %>", "<%= path %>" ]
<% end %> |
Perhaps already possible but I see no obvious way to specify this in the yml files, but i would like to have something that could generate an optgroup, or alternatively, letting my disable a field.
Right now, we add hack this in via an extra option, which generates a drop down kind of like
which is OK, but of course unfortunately lets people select this non existent separator "User specified runtime ..." which just kind of breaks things for us.
Just having the option to specify
would at least remedy this, though not as nice as having the groups
┆Issue is synchronized with this Asana task by Unito
The text was updated successfully, but these errors were encountered: