Score:2

Conditional subelement within custom composite webform element

us flag

I have a webform that has a custom composite element; let's name it composite_name.

Within that custom composite, I have element_a, element_b, and element_c.

Is it possible to make element_c visible only when a value is entered in either element_a or element_b, by editing the composite element in the Webform UI?

I tried putting this in the custom properties for element_c, but it does not work:

states:
  visible:
    - ':input[name=["composite_name"]["element_a"]]':
        filled: true
    - or
    - ':input[name=["composite_name"]["element_b"]]':
        filled: true

I also tried a few variations on that, with no success. I don't know whether I just have some punctuation out of place or something.

It looks like I could make the condition happen using a custom module (following the webform_example_composite module's code), but I'm hoping to configure it in the UI.

Score:0
us flag

Conditions need to be set per row.

The webform_example_composite.module, included w/ Webform, shows how to do this via \Drupal\webform_example_composite\Element\WebformExampleComposite

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.