Inputs available to contact forms

Looking at this documentation here and trying to get some inputs working in contact forms.

Are these inputs/[contact_type]/… inputs only available when editing?

I did not try actually referencing them in a form, but based on the code it seems like type, contact_type, and parent should all be present when adding a contact. When rendering a create contact form, we set these three fields and then provide them as the instanceData. Then, this data should be prepopulated in the form if there are any nodes matching those names.

Ohhh. When creating a contact, parent is just an id - not an object.
When editing the contact, parent seems to become an object.

Create Form:
image

Edit Form:
image

Is that right?

Right. When editing a contact, all of the data for the contact is provided in the group (e.g. when editing a person, all the person’s existing data is available in the person group). The lineage of the contact has been hydrated so all of the data is available from the contact’s parent doc (in the parent group).

Docs PR for including this information on the Form Inputs page: Document contact parent data available on edit form by jkuester · Pull Request #944 · medic/cht-docs · GitHub

Thanks for explaining and for making that change. That helps.

I think what I found confusing was that the contact variable inside the input changes behavior in the two scenario. When things aren’t working as expected, it’s tough to debug these scenarios without trial-and-error.

1 Like