Skip to content

Dynamic form JS data-hide only takes into account last change #4719

@JarneRenders

Description

@JarneRenders

Hi,

There seems to be a bug in the way that the data-hide option is handled, where sometimes an item A does not remain hidden even though a certain option is set which contains data-hide-A: true. This occurs whenever there are multiple select fields that can have an impact on the visibility of A. In this case the visibility of A is determined solely by the select field in which the last change occurred, regardless of the value of the other select field.

Example form.yml:

---
# app-specific attributes
attributes:
  dummy1:
    label: "Dummy 1"
  dummy2:
    label: "Dummy 2"
  test1:
    widget: "select"
    options:
      - ["hide dummy 1", "c", data-hide-dummy1: true]
  test2:
    widget: "select"
    options:
      - ["hide dummy 1", "a", data-hide-dummy1: true]
      - ["hide dummy 2", "b", data-hide-dummy2: true]

form:
  - dummy1
  - dummy2
  - test1
  - test2

Expected behaviour: dummy1 should be hidden because test1 always has option c set.
Actual behaviour: dummy1 is hidden when test2 has option a set, changing to option b hides dummy2, but reveals dummy1, regardless of test1's value.

I encountered this issue when trying to swap between a "gpu" or "shard" item depending on the cluster, but wanting to always hide both of these items if the selected queue does not support it. Since changing clusters also changes the available queues, the settings of the queue options determined what was visible regardless of the cluster options. Such behaviour seems not to be possible at the moment.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Reviewed, Not Scheduled

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions