Formio:- 在未填写必填字段的情况下按下提交按钮时的自定义错误消息

Formio:- Custom Error Message when the submit button is pressed without filling the required fields

我想更改在单击提交按钮时显示的错误消息,但某些必填字段为空。我默认收到的消息是“请检查表格并在提交表格前更正所有错误”。我想改用自定义消息。有办法实现吗?

您可以通过在创建表单时添加选项来覆盖错误消息:

var options = {
   i18n: {
            en: {
                  submitError: 'My custom submission error',
            }
   }
}

稍后您可能会打电话给 Formio.createForm(Formio.createForm(document.getElementById(settings.id), formDefinitionUrl, 选项) 这是您需要的选项对象所在的位置。

这是您可以通过这种方式覆盖的字符串列表:https://github.com/formio/formio.js/blob/master/src/translations/en.js