gpt4 book ai didi

javascript - 验证 apostrope cms 中的 bool 字段 apostrope-pieces-submit-widgets

转载 作者:行者123 更新时间:2023-12-03 00:08:59 25 4
gpt4 key购买 nike

我正在尝试使用 apostrope-pieces-submit-widgets 构建一个简单的联系表单,并且需要勾选 GDPR。我设置了一个请求表单模块:

module.exports = {
extend: 'apostrophe-pieces',
name: 'request-form',
label: 'Request Form',
alias: 'requestForm',
addFields: [
...
{
name: 'gdpr',
label: 'Marketing agreement',
type: 'boolean',
required: true
}
],
//stuff like building title field and marking it as published when it's saved
...
}

然后我使用apostrope-pieces-submit-widgets显示它:

module.exports = {
extend: 'apostrophe-pieces-submit-widgets',
fields: ['name', 'email', 'phone', 'gdpr']
}

它在视觉上工作,即它标有星号,唉,您仍然可以发送表单而无需将其切换为。当您不填写其他必填字段时,它永远不会像其他字段一样在返回的错误对象中提及。我需要做什么来验证它?

最佳答案

您现在可以通过为字段设置 mandatory: true 选项来执行此操作。

关于javascript - 验证 apostrope cms 中的 bool 字段 apostrope-pieces-submit-widgets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54829021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com