Conditional Dependencies

Alpaca extends JSON Schema's dependencies capabilities by allowing you to define conditional dependencies where dependencies are only valid based on conditional value matches with other fields. This lets you get more precise with your dependency management.

If you want to go further and wire together completely custom form inter-dependencies that have little or nothing to do with the underlying JSON Schema definition, take a look at Alpaca's support for observables and events. These let you wire together fields and plug in custom data source loaders so that values can be acquired on the fly as people use your form.

Simple Example

Here is the Ice Cream Picker example from the dependencies page. In this example, the schema is similar (it's standard JSON schema). However, in the options block we provide some more information allowing us to specify that certain dependent fields should only appears when specific values are selected for the choice field.

{% raw %} {% endraw %}

Registration Form

Here is a simple registration form that lets people provide some information and then indicate whether they will be bringing their own meals to the event. If they are not bringing their own meals, they can pick a meal plan to be provided to them.

{% raw %} {% endraw %}

Multi-Level / Nested Example

Demonstrates multi-level nested conditionals. Everything is wrapped in a form so you can inspect the JSON by clicking "Inspect".

{% raw %} {% endraw %}

Arrays of Values

Conditional dependencies can also leverage arrays of possible values.

{% raw %} {% endraw %}