Atlas Forms
Dynamic Binding
Dynamic binding allows the path used in a binding to be resolved at runtime from an expression, rather than being a static string in the schema. This is useful when the target path depends on a value chosen earlier in the form — for example, binding to items[{selectedIndex}].price.
Dynamic Path Expression
Prefix the path with expr: to signal that it is an expression, not a literal path. The expression is evaluated using the form's current value map:
// Static path (always binds to items[0].price):
"binding": { "source": "$json", "path": "items[0].price" }
// Dynamic path (binds to items[n].price where n comes from another field):
"binding": {
"source": "$json",
"path": "expr:items[values['selected-index']].price"
}
Example — Item Detail Form
A user selects a line item from a grid, then edits its details in a separate panel. The detail fields dynamically bind to the selected item's index:
// Form schema (abridged)
{
"controls": [
// Hidden field — populated programmatically when user clicks a row
{
"id": "selected-index",
"type": "hidden",
"binding": { "source": "$json", "path": "selectedIndex" }
},
// Detail fields — paths depend on selected-index
{
"id": "item-name",
"type": "text",
"label": "Item Name",
"binding": {
"source": "$json",
"path": "expr:items[values['selected-index']].name"
}
},
{
"id": "item-price",
"type": "number",
"label": "Unit Price",
"binding": {
"source": "$json",
"path": "expr:items[values['selected-index']].price"
}
}
]
}
// When the user selects row 2:
engine.setValue('selected-index', 2);
// item-name now reads from items[2].name
// item-price now reads from items[2].price
Expression Evaluation Rules
- Expressions are evaluated using the same expression engine as
visibilityRule - The expression has access to the
valuesobject (current form value map) - The expression must evaluate to a valid path string
- Expressions are re-evaluated whenever the value map changes — the binding path updates reactively
- If the expression throws or returns a non-string, the path is treated as undefined and the control value is
undefined
When Not to Use Dynamic Binding
| Scenario | Better Approach |
|---|---|
| The path is always static | Use a plain path string — simpler and faster |
| You need to show an array of items | Use a repeater control — designed for this use case |
| The path depends on a server-side value | Compute the path server-side and pass as a static schema string at load time |
Dynamic Binding Has Performance Overhead
Every change to the value map triggers re-evaluation of all dynamic path expressions. For forms with many dynamic bindings, this can cause extra re-render cycles. Prefer static paths where possible, and use dynamic binding only when the path genuinely cannot be known at schema authoring time.