The contactGroupAdd attribute requires the ID of a Group. To find the group ID, go to Dashboard > Customers > Groups > Find the
Group, click "Edit Properties".
Need to add the Contact to multiple groups? Simply separate each Group with commas (,).
An Alternate Method: Use Automation
Oncord's Marketing Automation feature can be used to add Contacts to a Group when a form submission takes place. This can be safer -
avoiding an error in the Group has been deleted.
Click here to learn more about using Oncord's Automation
feature.
Combobox to Select a Group
You can further customize the solution above to allow the user to select a group from a combobox.
This approach is commonly used to help sort contacts into groups based on why they enquired.
The Combobox dropdown will populate with groups dynamically (eg. populate with all child groups of the group with id
= '/what-can-we-help-with/').
To get started, setup a heirachy of groups via Dashboard > Customers > Groups:
Add a combobox to the form, where the options for the combobox populate dynamically with groups:
<forms:row label="What can we help you with?">
<forms:combobox title="What Can We Help You With?" id="form_reason" datatitle="$group['group_title']" as="group" datavalue="$group['group_id']" datasource="\Components\Customers\Groups::getChildren('/what-can-we-help-with/')" validations="mandatory" />
</forms:row>
You will also need to add some additional attributes to the form:
contactgroupadd="$form_reason.value" Instead of defining a group ID, update the contactGroupAdd attribute, so that it
uses the value of the combobox with ID=form_reason.
Here is the final solution:
<forms:form id="lead_capture" contactgroupadd="[? $form_reason.value ?]" recordsubmissions="true" onsubmitredirect="/success/" contactmode="store">
<forms:row label="First and Last Names">
<forms:editbox id="contact_first_name" width="80" validations="mandatory" />
<forms:editbox id="contact_last_name" width="110" validations="mandatory" />
</forms:row>
<forms:row label="E-mail Address">
<forms:editbox id="contact_email" width="200" validations="mandatory,email" transformations="tolower" />
</forms:row>
<forms:row label="What can we help you with?">
<forms:combobox title="What Can We Help You With?" id="form_reason" datatitle="$group['group_title']" as="group" datavalue="$group['group_id']" datasource="\Components\Customers\Groups::getChildren('/what-can-we-help-with/')" validations="mandatory" />
</forms:row>
<forms:row type="one_column" align="center">
<forms:submitbutton value="Submit" />
</forms:row>
</forms:form>
Checkboxes to Add to Multiple Groups
Taking the above example a step further, you can allow users to select multiple groups by employing checkboxes instead of a drop-down
combobox: