One form can do more than fill in a single record. It can create a record in one object, create a related record in another, and link the two, all in one submission. Say you're a veterinarian. When a new client fills out your form, you want a record for the pet, a contact record for the owner, and the two connected, without any data entry on your end. In this lesson, you'll build that form.
First, set up your custom object and its relationship, as you did in the earlier lessons. Custom objects need a Dynamic CMS package on your account. Here, Pets is related to Contacts in a one-to-many relationship. A pet has one owner, and an owner can have many pets, so Pets is the child.
A form connects records by drilling in. That means adding fields from the related object right onto your form. Drilling in works for one-to-one and one-to-many relationships. For one-to-many, your form's source must be the child object. So the vet builds a Pets form and drills into the owner's fields. For one-to-one, you can build the form from either object. Many-to-many relationships can't be connected by drilling in. They use a form setting instead, which you'll see at the end.
You'll build this form on an Ontraport Page. Click Pages in the top navigation, then New page, or open an existing page. Add a block to hold your form. Then, from the Forms & Sales section of the elements panel on the left, drag a Form Field element into the block.
When you add the Form Field element, select an object. This decides the type of record your form creates or updates. Choose the child object, Pets. Then add one Form Field element for each field you want, starting with the pet's own fields, like its name and type of animal.
To add the owner's fields, find the related field, like Pet owner, and click the arrow on the right of its name. That drills into the related object, so you can choose the owner's name and email address. Drilling in works with hidden fields too, not just visible ones.
Here's the same idea in the Support Center's example. Deals is the child, so this Deals form drills into the contact's name and email. Each submission creates a deal and a contact, and puts that contact in the deal's Primary contact field.
And here's a one-to-one example. This Contacts form drills into a spouse's fields, so one submission creates two contact records, linked by the Spouse field.
Two things to watch. Include every required field for both records. If a required field is missing, the submission still goes through, but no record is created. And multi-step forms only work with contacts, so keep a custom object form to a single step.
While Contacts is your only object, stand-alone forms are under Automations, then Forms. Once you've added custom objects, the Automations item goes away, and you'll find forms by hovering over each object in the top navigation, like Contacts or Pets.
Every form needs a Submit button, and you can't publish your page until your form has one. Drag in a Submit Button element. Then hover over it, click the settings gear, and click Form settings to set up the form the same way you would any other. When you're done, publish your page.
Now test it. Fill out the form as a new client, with a pet's name and type, and the owner's name and email. Open the new pet record, and its Pet owner field shows the owner. Open the owner's contact record, and the pet is listed there. One submission, two records, already connected.
For a many-to-many relationship, like events and the contacts who register for them, use a form setting instead. Open Form settings and scroll down to Advanced Settings. Check Update relationships on form submission, click Add, and choose the relationship to update. Then pick which records it connects: the visiting contact, the dynamic page record, the dynamic block record, or the form record, which is the record your form creates or updates.
For example, a registration form on an event's dynamic page can connect the form record with the dynamic page record. Each person who registers is then added to that event's Registered guests.
So: set up your relationship, build the form on the child object, drill into the related fields, and test it. For many-to-many, use Update relationships on form submission. Next up: relationship management, where you'll update existing records and change relationships with forms and automations.