# Easier dynamic label changes

**URL:** https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241
**Category:** Get Help
**Tags:** question
**Created:** [January 31, 2024, 11:53am UTC](https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241 "2024-01-31T11:53:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mnakao](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/mnakao/32/1001_2.png) [@mnakao](https://discourse.openondemand.org/u/mnakao)
#### Post date: [January 31, 2024, 11:53am UTC](https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241/1 "2024-01-31T11:53:10Z")

</div>

Hi,

The code below dynamically changes the content of the label depending on the node\_type choice. It is comfortable for users to know the minimum and maximum values before entering numbers in Web form.

```auto
form:
  - node_type
  - small_cores
  - medium_cores
  - large_cores

attributes:
  node_type:
    widget: select
    options:
      - ['small', 'small', data-hide-medium-cores: true, data-hide-large-cores: true]
      - ['medium', 'medium', data-hide-small-cores: true, data-hide-large-cores: true]
      - ['large', 'large', data-hide-small-cores: true, data-hide-medium-cores: true]

  small_cores:
    widget: "number_field"
    label: "Number of cores (1 - 4)"
    required: true
    value: 1
    min: 1
    max: 4
    step: 1

  medium_cores:
    widget: "number_field"
    label: "Number of cores (1 - 8)"
    required: true
    value: 1
    min: 1
    max: 8
    step: 1

  large_cores:
    widget: "number_field"
    label: "Number of cores (1 - 16)"
    required: true
    value: 1
    min: 1
    max: 16
    step: 1

```

This code has two problems.

The first is that it is long and complex.

The second is a special case. For example, change the minimum values of small\_cores, medium\_cores, and large\_cores from 1 to 2. After running “Restart Web Server”, even if I enter “2” in small\_cores and click the “Launch” button, nothing seems to occur.  
The reason is that the previous information, the value “1”, is cached in medium\_cores and large\_cores. To resolve this issue, you need to delete the cache file or add an option to form.yml to disable the cache.  
In other words, the above code makes it difficult to change settings.

Changing the maximum value of each item can be achieved by adding data-max-small-cores etc. to the node\_type options, but changing the label is not supported.

So, my question is, is there an easy way to dynamically change the label?  
Or do you have any plans to do so?

Best Regards,

---

<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: [January 31, 2024, 2:41pm UTC](https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241/2 "2024-01-31T14:41:21Z")

</div>

> [@mnakao](#):
>
> So, my question is, is there an easy way to dynamically change the label?  
> Or do you have any plans to do so?

No, I don’t believe there’s anyway currently to reset the label. I did create this ticket for our backlog though.

> <https://github.com/OSC/ondemand/issues/3327>
>
> From this discourse topic - someone is asking for the ability to relabel batch c…onnect items. 
> 
> It's unclear to me off the top what this directive would look like, but it seems like it should act like \`data-set\` directives.
> 
> Maybe \`data-label-foo: 'Bar'\` would relabel the \`foo\` form item to \`Bar\`.
> 
> https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241

---

<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: [July 29, 2024, 2:41pm UTC](https://discourse.openondemand.org/t/easier-dynamic-label-changes/3241/3 "2024-07-29T14:41:44Z")

</div>

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