APIs & Integrations

LaurensBakker
Contributor

forms API: placeholder text missing

We're trying to copy a form using the API. We're doing the following:

  • GET /forms/v2/forms/{guid}
  • modify the 'name' property in JSON
  • remove deprecated properties from JSON
  • remove derived data (guid, create/modification date) from JSON
  • POST /forms/v2/forms

This works, but the Placeholder text does not get created. In JSON this is the formFieldGroups[].fields[].unselectedLabel field.

 

Example JSON:

{ "name": "Foleon - Business Valuation Program", "method": "POST", "cssClass": "hs-form stacked", "redirect": "", "submitText": "Download brochure", "notifyRecipients": "", "formFieldGroups": [ { "fields": [ { "name": "firstname", "label": "", "type": "string", "fieldType": "text", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [], "validation": { "name": "", "message": "", "data": "", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "Voornaam *", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] }, { "name": "lastname", "label": "", "type": "string", "fieldType": "text", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [], "validation": { "name": "", "message": "", "data": "", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "Achternaam *", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] } ], "default": true, "isSmartGroup": false, "richText": { "content": "" } }, { "fields": [ { "name": "email", "label": "", "type": "string", "fieldType": "text", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [], "validation": { "name": "", "message": "", "data": "", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "E-mail *", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] } ], "default": true, "isSmartGroup": false, "richText": { "content": "" } }, { "fields": [ { "name": "career_stage", "label": "", "type": "enumeration", "fieldType": "select", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [ { "label": "Young Professional", "value": "Young Professional", "displayOrder": 1, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false }, { "label": "Professional", "value": "Professional", "displayOrder": 2, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false }, { "label": "Executive", "value": "Executive", "displayOrder": 4, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false } ], "validation": { "name": "", "message": "", "data": "", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] } ], "default": true, "isSmartGroup": false, "richText": { "content": "" } }, { "fields": [ { "name": "vooropleiding", "label": "", "type": "enumeration", "fieldType": "select", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [ { "label": "MBO", "value": "MBO", "displayOrder": -1, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false }, { "label": "HBO", "value": "HBO", "displayOrder": 1, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false }, { "label": "WO", "value": "WO", "displayOrder": 2, "doubleData": 0.0, "hidden": false, "description": "", "readOnly": false } ], "validation": { "name": "", "message": "", "data": "", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] } ], "default": true, "isSmartGroup": false, "richText": { "content": "" } }, { "fields": [ { "name": "phone", "label": "", "type": "string", "fieldType": "text", "description": "", "displayOrder": -1, "required": true, "selectedOptions": [], "options": [], "validation": { "name": "", "message": "", "data": "7:20:true", "useDefaultBlockList": false, "blockedEmailAddresses": [] }, "hidden": false, "defaultValue": "", "isSmartField": false, "placeholder": "Telefoonnummer *", "dependentFieldFilters": [], "propertyObjectType": "CONTACT", "metaData": [] } ], "default": true, "isSmartGroup": false, "richText": { "content": "" } } ], "ignoreCurrentValues": false, "deletable": true, "inlineMessage": "<p>Bedankt voor je brochure aanvraag. De brochure sturen wij naar jouw e-mailadres.</p>", "captchaEnabled": false, "cloneable": true, "editable": true, "deletedAt": 0, "themeName": "legacy", "parentId": 36070, "style": "{\"fontFamily\":\"arial, helvetica, sans-serif\",\"backgroundWidth\":\"100%\",\"labelTextColor\":\"#33475b\",\"labelTextSize\":\"13px\",\"helpTextColor\":\"#7C98B6\",\"helpTextSize\":\"11px\",\"legalConsentTextColor\":\"#33475b\",\"legalConsentTextSize\":\"14px\",\"submitColor\":\"#4ec535\",\"submitAlignment\":\"left\",\"submitFontColor\":\"#ffffff\",\"submitSize\":\"15px\"}", "isPublished": false, "publishAt": 0, "unpublishAt": 0, "publishedAt": 0, "multivariateTest": { "variants": [], "startAtTimestamp": 0, "endAtTimestamp": 0, "winningVariantId": "", "finished": false, "controlId": "" }, "kickbackEmailWorkflowId": 0, "kickbackEmailsJson": "" }

0 Upvotes
4 Replies 4
WendyGoh
HubSpot Employee
HubSpot Employee

forms API: placeholder text missing

Hi @LaurensBakker,

 

I hope all is well with you 😄

 

When trying to create a form using the code you provided, I'm able to see that the firstname, lastname, email and telephone placeholder got sent through. The placeholder was missing for both the dropdown list, is that the missing placeholder fields that you'd like to populate?

 

If that's the case, to populate the dropdown list placeholder you'll need to use the following property:

"unselectedLabel": "Placeholder for dropdown list"

Whereas for text field, you can use the placeholder property.

 

After modification, the code below have placeholder set for the dropdown fields as well:

 

{ 
   "name":"Foleon - Business Valuation Program3",
   "method":"POST",
   "cssClass":"hs-form stacked",
   "redirect":"",
   "submitText":"Download brochure",
   "notifyRecipients":"",
   "formFieldGroups":[ 
      { 
         "fields":[ 
            { 
               "name":"firstname",
               "label":"",
               "type":"string",
               "fieldType":"text",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 

               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
               "placeholder":"Voornaam *",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            },
            { 
               "name":"lastname",
               "label":"",
               "type":"string",
               "fieldType":"text",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 

               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
               "placeholder":"Achternaam *",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            }
         ],
         "default":true,
         "isSmartGroup":false,
         "richText":{ 
            "content":""
         }
      },
      { 
         "fields":[ 
            { 
               "name":"email",
               "label":"",
               "type":"string",
               "fieldType":"text",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 

               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
               "placeholder":"E-mail *",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            }
         ],
         "default":true,
         "isSmartGroup":false,
         "richText":{ 
            "content":""
         }
      },
      { 
         "fields":[ 
            { 
               "name":"career_stage",
               "label":"",
               "type":"enumeration",
               "fieldType":"select",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 
                  { 
                     "label":"Young Professional",
                     "value":"Young Professional",
                     "displayOrder":1,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  },
                  { 
                     "label":"Professional",
                     "value":"Professional",
                     "displayOrder":2,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  },
                  { 
                     "label":"Executive",
                     "value":"Executive",
                     "displayOrder":4,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  }
               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
"unselectedLabel":"This is dropdown list 1",
               "placeholder":"",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            }
         ],
         "default":true,
         "isSmartGroup":false,
         "richText":{ 
            "content":""
         }
      },
      { 
         "fields":[ 
            { 
               "name":"vooropleiding",
               "label":"",
               "type":"enumeration",
               "fieldType":"select",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 
                  { 
                     "label":"MBO",
                     "value":"MBO",
                     "displayOrder":-1,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  },
                  { 
                     "label":"HBO",
                     "value":"HBO",
                     "displayOrder":1,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  },
                  { 
                     "label":"WO",
                     "value":"WO",
                     "displayOrder":2,
                     "doubleData":0.0,
                     "hidden":false,
                     "description":"",
                     "readOnly":false
                  }
               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
"unselectedLabel":"This is dropdown list 2",
               "placeholder":"dropdown list 2",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            }
         ],
         "default":true,
         "isSmartGroup":false,
         "richText":{ 
            "content":""
         }
      },
      { 
         "fields":[ 
            { 
               "name":"phone",
               "label":"",
               "type":"string",
               "fieldType":"text",
               "description":"",
               "displayOrder":-1,
               "required":true,
               "selectedOptions":[ 

               ],
               "options":[ 

               ],
               "validation":{ 
                  "name":"",
                  "message":"",
                  "data":"7:20:true",
                  "useDefaultBlockList":false,
                  "blockedEmailAddresses":[ 

                  ]
               },
               "hidden":false,
               "defaultValue":"",
               "isSmartField":false,
               "placeholder":"Telefoonnummer *",
               "dependentFieldFilters":[ 

               ],
               "propertyObjectType":"CONTACT",
               "metaData":[ 

               ]
            }
         ],
         "default":true,
         "isSmartGroup":false,
         "richText":{ 
            "content":""
         }
      }
   ],
   "ignoreCurrentValues":false,
   "deletable":true,
   "inlineMessage":"<p>Bedankt voor je brochure aanvraag. De brochure sturen wij naar jouw e-mailadres.</p>",
   "captchaEnabled":false,
   "cloneable":true,
   "editable":true,
   "deletedAt":0,
   "themeName":"legacy",
   "parentId":36070,
   "style":"{\"fontFamily\":\"arial, helvetica, sans-serif\",\"backgroundWidth\":\"100%\",\"labelTextColor\":\"#33475b\",\"labelTextSize\":\"13px\",\"helpTextColor\":\"#7C98B6\",\"helpTextSize\":\"11px\",\"legalConsentTextColor\":\"#33475b\",\"legalConsentTextSize\":\"14px\",\"submitColor\":\"#4ec535\",\"submitAlignment\":\"left\",\"submitFontColor\":\"#ffffff\",\"submitSize\":\"15px\"}",
   "isPublished":false,
   "publishAt":0,
   "unpublishAt":0,
   "publishedAt":0,
   "multivariateTest":{ 
      "variants":[ 

      ],
      "startAtTimestamp":0,
      "endAtTimestamp":0,
      "winningVariantId":"",
      "finished":false,
      "controlId":""
   },
   "kickbackEmailWorkflowId":0,
   "kickbackEmailsJson":""
}

And this is the form that was being created using the above code on my own portal:

placeholder.png

 

Hope this helps to further clarify things!

 

0 Upvotes
LaurensBakker
Contributor

forms API: placeholder text missing

Hi Wendy,

The Hubspot forms API docs state the following:

     "unselectedLabel": "", // DEPRECATED - this field is not used.

I'm a little hesitant to build on a feature that is officially deprecated. As I read it, it shouldn't work now, and even if it does, it may stop working at any time. Where could I find information on when this field stops working, and what replaces it?

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

forms API: placeholder text missing

Hi @LaurensBakker,

 

Here's an update! Our product team has pushed a fix for the form rendering to use the placeholder. 

 

Now you can use the placeholder for select's input and you'll see the placeholder in the rendered form.

WendyGoh
HubSpot Employee
HubSpot Employee

forms API: placeholder text missing

Hey @LaurensBakker,

 

Pardon for the delayed in response! I'd just like to let you know that I'm still looking into things here with my team and I'll keep you posted on what's the best field to use to populate the select input placeholder when creating form via API.

0 Upvotes