O3: Nested Form Structure and Conditional Field Support

Hello everyone,

The ICRC has come with an interesting feature that we’re trying to gauge the amount of community interest in. Currently they have a form which is very long, however most fields only need to be filled out if some predecessor was selected, or set to a specific value. The idea would be to hide most of the nested form and only render dependent fields after the predecessor was selected. Additionally, certain fields are only applicable if a specific option was chosen, and invalid or should be discarded if the field is set to not that value. Some examples to follow:

Trigger warning: The assets which we are able to share below contain topics of rape, abuse, and violence.

Let’s say on an intake form for a victims of violence program we are able to note the main type the patient experienced, either physical and/or emotional, sexual, or another specific type of violence. The initial indication might look like so.


After selecting the first option more question fields would appear so the clinician can report more detail about the specific violence the patient experienced, as seen below.

In addition to a nested form structure there is also a desire to support conditional fields. These should only be valid to exist if a predecessor was set to a specific value. For example below, the field “If raped, specify the time that passed since rape” should only show up and contain a value if the prior field “rape” was chosen. The form should not submit a value for this field if rape was not selected.

Please respond if either nested forms or conditional fields are of interest to your project, and note the form-engine you are using.



(Reference TFS-263277)

1 Like

This would definitely be useful. We do this with htmlforms today. If the high level is selected, it shows further choices.

We had a request yesterday but a slightly different use case. If “Victim of sexual violence” was selected, they want selection of 1 or more type of sexual violence. As you are designing this, I would add that feature.

This feature definitely is already part of the form engine.

1 Like

Conditional field support is a fundamental feature for forms, so something we should definitely strive to support. Is this already defined in the form schema? Do we have a formal documentation of the schema beyond the examples given in the AMPATH forms documentation on Vercel? (Assuming we need to propose schema changes to support conditional fields, I’d like to use the same process to propose referring to concepts by mapping)

The term “nested forms” might also be used to describe include forms (or components) by reference – i.e., embedding forms inside other forms. From your description, I think by “nested forms” you’re actually referring to “conditional sections” – i.e., the ability to apply conditions not only to individual fields but also to sections (groups of fields) within a form.

Good to know! Glad I asked.

Thanks for the clarification of terminology. I agree, conditional sections seems appropriate here. Should there be a design specification for tab-indentation for conditional sections which are direct subsets of another section?

Here it is:

Rendering Fields Conditionally

Including this caveat:

:information_source: Note that at the moment it is only possible to render questions conditionally. AMPATH Forms does not explicitly support hiding sections or pages.


Nice find @burke ! So of course now I’m wondering if it would be desired to extend AMPATH to support conditional rendering of sections? From my side it seems like a reasonable thing to allow for, assuming the notation is tractable.

@zacbutko best person to loop in to this conversation is @dkigen. He put a lot of time into the documentation that Burke linked to above. Definitely check all of that. Re. conditional rendering of sections - @dkigen are you aware of any plans/existing support for this? @dkibet or @aojwang do you think Palladium has interest in this as well?

We were able to do these using htmlformentry since we could basically control everything using javascript and the include if tags. I strongly suggest that Ampath forms can be enhanced to support such requirements. We are willing to participate in the designs but may not get time for dev work until end of Sep 2022.


I can confirm that this is presently achievable using AMPATH forms.

1 Like

During the last hackathon between Palladium and AMPATH, the team tasked with enhancing the form engine received requests to add this feature to the AMPATH form engine. That work hasn’t materialized, however. I know that Palladium would be interested in seeing this done. As far as AMPATH are concerned, I’m unaware of any past requests for this feature. If we can do this in an incrementally-adoptive way that doesn’t break what’s already there, I’m all for it!

1 Like

Doing this would just be a matter of having something like a hideWhenExpression property on, e.g., sections and pages? That seems straight-forward enough to implement in a backwards-compatible way… (Note that I mean the backwards-compatibility is straight-forward, not necessarily the implementation itself).

1 Like