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.
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,