Show/Hide form fields based on other form field values

I'm relatively new to the Retool / SQL / JS world so please bare with me if my terminology or ideas of what this platform is capable of are off.

I have a form with multiple fields and I want to show and hide other fields based on specific conditions being met from the value of fields.

For example: my basic form has 3 fields:


How do I dynamically add or remove additional fields based on the original field values? By dynamically I mean that the form with change on the fly for each scenario and reset to default when complete.

Example: if Age = 18 then show 2 additional fields called "Favourite alcohol" & "Favourite pub" and if not then continue to hide those fields.

And to push it further how could I stack multiples?

if Age = 0-16 dont change and
if Age = 18,19,20 show X Fields and
if Age=21,22,33 show Y Fields and
if Age=24,25,26 show Z Fields

For some context, I am building an event log form to write to a SQL table but I have some clients that require additional information and some that just need basic information. To make it operator friendly I don't want to always show all fields and I don't want to have to make multiple variants of the same form because that would require the operator to know which form to use for each client. If the form can be dynamic based on what client is selected then my operator has an easier time filling out the forms.

@rcanpolat Welcome to the forum!
Depending on you are detecting the "Age" will matter, I will assume that there is some value already set in a field or payload somewhere when the user views the form...
In the X Fields you want to show, use the Hidden field in the Inspect panel and add the following
{{somfieldthatcontainsAge.value != 18 && somfieldthatcontainsAge.value != 19 && somfieldthatcontainsAge.value != 20}}
This X Field will evaluate to true only when all 3 conditions are met. This means the X field remains hidden when the AGE = 18, 19, or 20 but will appear in the form for the operator when the Age is equal to 18, 19, or 20
You can then apply the same logic to Y and Z fields.

1 Like

Cool, I'll have a play around with it tomorrow at work and see if I can get it working. Thanks for the quick response.