Dependent field setup based on multiple fields

Dependent field setup based on multiple fields

bfarkasbfarkas Posts: 181Questions: 48Answers: 0

Hi,
All the dependent api examples pull in one fields value and then you make decisions based on it that can effect other fields.
Is it possible to bring in multiple fields to do more complex checks, i.e. hide fields until at least 1 of 3 fields has a value in it?
Anyone have an example to refer to of this type of thing working?
Thanks!
Brian

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    I haven't tried it but it looks like the field parameter of the dependent() API can be either a string or an array of fields.

    Kevin

  • bfarkasbfarkas Posts: 181Questions: 48Answers: 0

    Thanks Kevin, looks like you are right, will have to give a try. Do you then call the specific val of the member of the array you are currently looking for? i.e. field1.val field2.val, field3.val
    I find it interesting that I can't find any examples of something like this, surprised more people don't run into it.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    edited November 2020 Answer ✓

    Yep, agreed, I'll update the docs with an example of this. The value will be any one of those in the array that changed (only one can change at a time) - you can then use data.values to get the values of the entire record. Hopefully this example here will make that clear.

    Colin

  • bfarkasbfarkas Posts: 181Questions: 48Answers: 0

    Perfect, thanks Colin, giving it a go now but seems pretty straight forward.
    Thanks,
    Brian

This discussion has been closed.