首页 > 解决方案 > 自定义 Hubspot 表单错误消息(使用 react.js)

问题描述

只是想知道是否有人有使用 react.js 嵌入 Hubspot 表单的经验

我们的一个页面中嵌入了一个 hubspot 表单。

这是设置表单的当前代码组件:

         <HubspotForm
            portalId="xxxxxxx"
            formId="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            onSubmit={() => null}
            onReady={() => this.registerListeners()}
            loading={<div>Loading...</div>}
            css={hubspotcss}
            cssClass="hubspotForm"
          />

我要做的就是修改企业电子邮件字段的错误消息。所以我检查了https://developers.hubspot.com/docs/methods/forms/advanced_form_options

并找到自定义国际化部分来覆盖错误消息。据我所知,我需要添加以下代码:

          locale="en"
            translations= {
              en= {
                forbiddenEmailDomain= "Please enter a company email address"
              }
          }

但是当我编译代码时出现错误:错误'locale' is not defined no-undef

任何人都必须知道我做错了什么?非常感谢任何信息

谢谢乔尔斯

标签: javascriptreactjsgatsbyhubspot

解决方案


在@Ferran Buireu 的建议之后,我发现这对我有用。

translations={{
en:{
    forbiddenEmailDomain: "Please enter a company email address."
   }
}}

推荐阅读