Bind existing fields
Use case: the host already has a form (SwiftUI, DOM, or another toolkit). Keep those widgets. Map each one to a Comprehendly element so voice and save use the same values.
Mapping
Prefer element.id from forms.page.get. Persist that id in your app (accessibility identifier, data-element-id, etc.).
client.store.bind({ elementId: 'el-mood' }, (value) => {
hostInput.value = value ?? ''
})
hostInput.addEventListener('input', () => {
client.store.set({
elementId: 'el-mood',
value: hostInput.value,
source: 'bind'
})
})
Swift:
try client.store.bind(elementId: "el-mood") { value in
mood = value as? String ?? ""
}
try client.store.set(elementId: "el-mood", value: mood, source: "bind")
Partial mapping
You do not have to bind every field. Unmapped fields still receive voice patches in the store.
Either ignore them or show an “also captured” list from store.values().
When bind is required
- Custom layout or CSS the generated list cannot reproduce.
- Conditional sections you already implement in the host.
- Controls the SDK does not render yet (rating, score, tree, signatures).
Do not draw a second Comprehendly form on top of host controls. One widget per field.