【发布时间】:2021-03-16 06:09:30
【问题描述】:
在我们的 Meteor v1.11.1 应用程序中,我们在 blaze 中使用 Bootstrap 3、aldeed:autoform@6.3.0 和 aldeed:collection2@3.2.1 来验证表单。我们真的很想实现“最少定制”的解决方案来显示和验证我们的表单输入。
我们无法理解为什么在提交时连最基本的错误消息都没有出现在表单中?我们将表单缩小到一个字段和一个提交。 HTML 元素位于 DOM 中,但在验证时不会出现消息提示。
表单的架构是:
Folios = new Mongo.Collection('Folios')
FolioSchema = new SimpleSchema({
"name": {
"type": String,
"min": 2,
"required": true
}
},
{
"requiredByDefault": false,
"clean": {
"filter": true,
"autoconvert": true,
"removeEmptyStrings": true,
"trimStrings": true,
"getAutoValues": true,
"removeNullsFromArrays": true
}
}
Folios.attachSchema(FolioSchema)
形式为:
{{# autoForm id="newFolio"
class="newFolioForm"
collection=getFormCollection
schema=getFormSchema
type=getFormType
validation="submitThenBlur"
resetOnSuccess=true
}}
{{> afQuickField name='name' type='text' }}
<button type="submit">Submit</button>
{{/ autoForm }}
collection、schema 和 type 的助手是:
Template.newFolioForm.helpers({
getFormCollection()
{
return Folios
},
getFormSchema()
{
return FolioSchema
},
getFormType()
{
return "insert"
}
})
当我点击提交时,没有错误消息,没有错误类,什么都没有。我们咨询了simpl-schema docs。我们希望避免将 afMessage 实现为完全自定义表单的一部分,只是为了让消息和验证错误正确显示。
我想先检查这里。谢谢!
【问题讨论】:
标签: javascript meteor meteor-blaze