角度架构表单+突出显示表单加载时出错的字段

时间:2016-05-23 05:55:22

标签: angularjs angular-schema-form

我正在使用角度架构表单。我遇到的问题是,当我尝试加载表单时,有一些必需的属性丢失了!表格没有表明遗漏的属性。但是,当我点击该特定字段并编辑某些内容然后将其删除时,它会显示为我突出显示该字段。我希望这也发生在初始加载时。寻找指针。感谢

2 个答案:

答案 0 :(得分:0)

您需要在表单配置架构中使用必需的属性:

//..other fields
"required": [
    "name",
    "email",
    "comment"
  ]

检查demo here,它还包含必填字段:

{
  "type": "object",
  "title": "Comment",
  "properties": {
    "name":  {
      "title": "Name",
      "type": "string"
    },//here validation details
    "email":  {
      "title": "Email",
      "type": "string",
      "pattern": "^\\S+@\\S+$",
      "description": "Email will be used for evil."
    },
    "comment": {
      "title": "Comment",
      "type": "string",
      "maxLength": 20,
      "validationMessage": "Don't be greedy!"
    }
  },//here naming fields required
  "required": ["name","email","comment"]
}

答案 1 :(得分:0)

该属性为validateOnRender: true

需要将其添加到表单global options object