Skip to content

Commit 26f1ead

Browse files
authored
Update create-form.mjs
Added a thorough and complete description of the fieldGroups parameter
1 parent 1725ae6 commit 26f1ead

File tree

1 file changed

+93
-1
lines changed

1 file changed

+93
-1
lines changed

components/hubspot/actions/create-form/create-form.mjs

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,99 @@ export default {
2727
fieldGroups: {
2828
type: "string[]",
2929
label: "Field Groups",
30-
description: "A list for objects of group type and fields. **Format: `[{ \"groupType\": \"default_group\", \"richTextType\": \"text\", \"fields\": [ { \"objectTypeId\": \"0-1\", \"name\": \"email\", \"label\": \"Email\", \"required\": true, \"hidden\": false, \"fieldType\": \"email\", \"validation\": { \"blockedEmailDomains\": [], \"useDefaultBlockList\": false }}]}]`** [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/forms#post-%2Fmarketing%2Fv3%2Fforms%2F) for more information.",
30+
description: `Array of stringified JSON objects defining form field groups. Each string must contain a complete field group object.
31+
32+
**FIELD GROUP STRUCTURE:**
33+
Each field group object requires:
34+
- \`groupType\` (string, required) - Values: "default_group" (standard display), "progressive" (conditional reveal), "queued" (sequential)
35+
- \`richTextType\` (string, required) - Values: "text" (HTML/text content), "image" (image content)
36+
- \`richText\` (string, optional) - HTML/text content or image URL to display above fields
37+
- \`fields\` (array, required) - Array of field objects
38+
39+
**FIELD OBJECT STRUCTURE:**
40+
Each field in the \`fields\` array MUST include ALL of these properties:
41+
- \`objectTypeId\` (string, required) - CRM object type: "0-1" (Contact), "0-2" (Company), "0-3" (Deal), "0-5" (Ticket)
42+
- \`name\` (string, required) - Unique field identifier (e.g., "email", "firstname", "company")
43+
- \`label\` (string, required) - Display label for the field
44+
- \`fieldType\` (string, required) - Field type (see FIELD TYPES below)
45+
- \`required\` (boolean, required) - Whether field must be filled
46+
- \`hidden\` (boolean, required) - Whether field is visible (hidden fields can still pass values)
47+
- \`validation\` (object, required) - Validation rules (can be empty object \`{}\` if no validation needed)
48+
- \`dependentFields\` (array, required) - Conditional logic array (can be empty \`[]\` if no dependencies)
49+
50+
**OPTIONAL FIELD PROPERTIES:**
51+
- \`placeholder\` (string) - Hint text for empty fields
52+
- \`description\` (string) - Help text below the field
53+
- \`defaultValue\` (string) - Pre-populated value
54+
55+
**FIELD TYPES & THEIR SPECIFIC REQUIREMENTS:**
56+
57+
*Text Types:*
58+
- \`"email"\` - Email input with validation
59+
- \`"single_line_text"\` - Single line text input
60+
- \`"multi_line_text"\` - Textarea for longer content
61+
- \`"phone"\` - Phone number input
62+
- \`"mobile_phone"\` - Mobile phone input
63+
64+
*Selection Types (require \`options\` array):*
65+
- \`"dropdown"\` - Dropdown menu. Add: \`"options": [{"label": "Display", "value": "internal"}]\`
66+
- \`"radio"\` - Radio buttons. Add: \`"options": [{"label": "Yes", "value": "true"}]\`
67+
- \`"multiple_checkboxes"\` - Multiple checkboxes. Add: \`"options": [{"label": "Option 1", "value": "opt1"}]\`
68+
- \`"single_checkbox"\` - Single checkbox
69+
70+
*Other Types:*
71+
- \`"number"\` - Numeric input
72+
- \`"datepicker"\` - Date selection
73+
- \`"file"\` - File upload
74+
- \`"payment_link_radio"\` - Payment options
75+
76+
**VALIDATION OBJECT EXAMPLES:**
77+
78+
*Email validation:*
79+
\`"validation": {"blockedEmailDomains": ["competitor.com"], "useDefaultBlockList": true}\`
80+
81+
*Number validation:*
82+
\`"validation": {"min": 0, "max": 100, "decimals": 2}\`
83+
84+
*Text validation:*
85+
\`"validation": {"minLength": 3, "maxLength": 50, "pattern": "^[A-Za-z]+$"}\`
86+
87+
*Date validation:*
88+
\`"validation": {"minDate": "2024-01-01", "maxDate": "2024-12-31"}\`
89+
90+
*File validation:*
91+
\`"validation": {"allowedExtensions": [".pdf", ".doc"], "maxFileSize": 5242880}\`
92+
93+
**DEPENDENT FIELDS STRUCTURE:**
94+
Each dependent field object in \`dependentFields\` array:
95+
\`{
96+
"fieldName": "targetFieldName", // Field to show/hide
97+
"objectTypeId": "0-1", // Object type of dependent field
98+
"controllingValue": "specificValue", // Value that triggers condition
99+
"condition": "EQUAL", // Condition type (see below)
100+
"active": true // Whether dependency is active
101+
}\`
102+
103+
**CONDITION TYPES:**
104+
- \`"EQUAL"\`, \`"NOT_EQUAL"\` - Exact match conditions
105+
- \`"CONTAINS"\`, \`"NOT_CONTAINS"\` - Text contains conditions
106+
- \`"IS_EMPTY"\`, \`"IS_NOT_EMPTY"\` - Presence conditions
107+
- \`"GREATER_THAN"\`, \`"LESS_THAN"\` - Numeric comparisons
108+
- \`"CHECKED"\`, \`"NOT_CHECKED"\` - Checkbox states
109+
110+
**COMPLETE EXAMPLE:**
111+
\`[
112+
"{\"groupType\":\"default_group\",\"richTextType\":\"text\",\"richText\":\"<h3>Contact Info</h3>\",\"fields\":[{\"objectTypeId\":\"0-1\",\"name\":\"email\",\"label\":\"Email\",\"fieldType\":\"email\",\"required\":true,\"hidden\":false,\"validation\":{\"useDefaultBlockList\":true},\"dependentFields\":[],\"placeholder\":\"you@example.com\",\"description\":\"We'll never share your email\"},{\"objectTypeId\":\"0-1\",\"name\":\"company_type\",\"label\":\"Company Type\",\"fieldType\":\"dropdown\",\"required\":true,\"hidden\":false,\"validation\":{},\"dependentFields\":[{\"fieldName\":\"enterprise_fields\",\"objectTypeId\":\"0-1\",\"controllingValue\":\"enterprise\",\"condition\":\"EQUAL\",\"active\":true}],\"options\":[{\"label\":\"Small Business\",\"value\":\"small\"},{\"label\":\"Enterprise\",\"value\":\"enterprise\"}]}]}"
113+
]\`
114+
115+
**IMPORTANT NOTES:**
116+
- Each array item must be a valid JSON string (use JSON.stringify if building programmatically)
117+
- ALL field properties listed as required MUST be included, even if empty
118+
- Field names must be unique within their objectTypeId
119+
- Hidden dependent fields should have \`"hidden": true\` initially
120+
- For HubSpot default fields, use standard names: "email", "firstname", "lastname", "phone", "company"
121+
122+
[See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/forms#post-%2Fmarketing%2Fv3%2Fforms%2F) for additional details.`,
31123
optional: true,
32124
},
33125
createNewContactForNewEmail: {

0 commit comments

Comments
 (0)