我是 Angular Schema Form 的新手,并且在select字段checkbox验证required方面遇到了一些问题。
在$scope.schema我有名为的选择字段designation:
"designation": {
"title": "Designation",
"type": "select",
"default": undefined
}
$scope.form(声明designation和agreeTerms):
{
"key": "designation",
"type": "select",
"title": "Designation",
"titleMap": [
{ value: undefined, name: "Select a designation" }, // first value
{ value: "Andersson", name: "Andersson" },
{ value: "Johansson", name: "Johansson" },
{ value: "other", name: "Something else..."}
]
},
{
"key": "agreeTerms",
"type": "checkbox",
"title": "I agree to ..."
}
两者designation和agreeTerms都在模式的required属性中定义。
当我提交表单时,两个字段都通过了required验证。我期望 UI 显示的是Required字段下方/之后的消息。那没有发生。
我尝试过的事情:
- 将选择字段的第一个值分配给
''并null与架构默认值匹配。 - 将
select字段类型更改object为架构中的;这有效并通过了所需的验证,但该属性未显示在模型中
请帮忙 :)