我正在使用Angular Schema Form为我生成输入字段。我想知道是否有任何方法可以通过添加ID来自定义输入字段。我试着查看文档(https://github.com/Textalk/angular-schema-form/blob/development/docs/index.md),但似乎并不像当前版本支持它(仅添加类)。将ID添加到角度模式表单的输入字段?
1
A
回答
0
我只是做了一些调查,对 “厨房水槽” 例如在 -
http://schemaform.io/examples/bootstrap-example.html
他们已经使用这个代码
形式:
`[
{
"type": "fieldset",
"title": "Stuff",
"items": [
{
"type": "tabs",
"tabs": [
{
"title": "Simple stuff",
"items": [
{
"key": "name",
"placeholder": "Check the console",
"onChange": "log(modelValue)",
"feedback": "{'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-star': !hasSuccess() }"
},
{
"key": "favorite",
"feedback": false
}
]
},
{
"title": "More stuff",
"items": [
"attributes.eyecolor",
"attributes.haircolor",
{
"key": "attributes.shoulders.left",
"title": "Left shoulder",
"description": "This value is copied to attributes.shoulders.right in the model",
"copyValueTo": [
"attributes.shoulders.right"
]
},
{
"key": "shoesizeLeft",
"feedback": false,
"copyValueTo": [
"shoesizeRight"
]
},
{
"key": "shoesizeRight"
},
{
"key": "invitation",
"tinymceOptions": {
"toolbar": [
"undo redo| styleselect | bold italic | link image",
"alignleft aligncenter alignright"
]
}
},
"things",
"dislike"
]
}
]
}
]
},
{
"type": "help",
"helpvalue": "<hr>"
},
"soul",
{
"type": "conditional",
"condition": "modelData.soul",
"items": [
{
"key": "soulserial",
"placeholder": "ex. 666"
}
]
},
{
"key": "date",
"minDate": "2014-06-20"
},
{
"key": "radio",
"type": "radios",
"titleMap": [
{
"value": "Transistor",
"name": "Transistor <br> Not the tube kind."
},
{
"value": "Tube",
"name": "Tube <br> The tube kind."
}
]
},
{
"key": "radio2",
"type": "radios-inline",
"titleMap": [
{
"value": "Transistor",
"name": "Transistor <br> Not the tube kind."
},
{
"value": "Tube",
"name": "Tube <br> The tube kind."
}
]
},
{
"key": "radiobuttons",
"style": {
"selected": "btn-success",
"unselected": "btn-default"
},
"type": "radiobuttons",
"notitle": true
},
{
"type": "actions",
"items": [
{
"type": "submit",
"style": "btn-info",
"title": "Do It!"
},
{
"type": "button",
"style": "btn-danger",
"title": "Noooooooooooo",
"onClick": "sayNo()"
}
]
}
]`
架构:
`{
"type": "object",
"required": [
"name",
"shoesizeLeft"
],
"properties": {
"name": {
"title": "Name",
"description": "Gimme yea name lad",
"type": "string",
"pattern": "^[^/]*$",
"minLength": 2
},
"invitation": {
"type": "string",
"format": "html",
"title": "Invitation Design",
"description": "Design the invitation in full technicolor HTML"
},
"favorite": {
"title": "Favorite",
"type": "string",
"enum": [
"undefined",
"null",
"NaN"
]
},
"shoesizeLeft": {
"title": "Shoe size (left)",
"default": 42,
"type": "number"
},
"shoesizeRight": {
"title": "Shoe size (right)",
"default": 42,
"type": "number"
},
"attributes": {
"type": "object",
"title": "Attributes",
"required": [
"eyecolor"
],
"properties": {
"eyecolor": {
"type": "string",
"format": "color",
"title": "Eye color",
"default": "pink"
},
"haircolor": {
"type": "string",
"title": "Hair color"
},
"shoulders": {
"type": "object",
"title": "Shoulders",
"properties": {
"left": {
"type": "string",
"title": "Left"
},
"right": {
"type": "string",
"title": "Right"
}
}
}
}
},
"things": {
"type": "array",
"title": "I like...",
"items": {
"type": "string",
"enum": [
"clowns",
"compiling",
"sleeping"
]
}
},
"dislike": {
"type": "array",
"title": "I dislike...",
"items": {
"type": "string",
"title": "I hate"
}
},
"soul": {
"title": "Terms Of Service",
"description": "I agree to sell my undying <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ'>soul</a>",
"type": "boolean",
"default": true
},
"soulserial": {
"title": "Soul Serial No",
"type": "string"
},
"date": {
"title": "Date of party",
"type": "string",
"format": "date"
},
"radio": {
"title": "Radio type",
"type": "string",
"enum": [
"Transistor",
"Tube"
]
},
"radio2": {
"title": "My Second Radio",
"type": "string",
"enum": [
"Transistor",
"Tube"
]
},
"radiobuttons": {
"type": "string",
"enum": [
"Select me!",
"No me!"
]
}
}
}`
从乍一看,它似乎在第一个输入字段上生成一个ID。所以我认为它与表格中的Key
和模式中的title
有关。
0
ID字段是从旧的0.x版本的密钥的最后一个段生成的,并且在下一个版本代码中为1.0.0及更高版本组合了表单名称和对象路径。
所以从1.0.0起,你将有类似正确的唯一的ID:
formName--objectName-arrayName-4-property
虽然类匹配,也将是一个版本一起使用,而不阵列的位置:formName--objectName-arrayName-property
的独特的ID和灵活的类的组合应该满足任何定制需求。
相关问题
- 1. 动态添加ID到输入字段
- 2. 角度:点击,添加输入字段文本到数组
- 3. 通过管理将输入字段添加到cakephp表单
- 4. 添加表单输入字段动态
- 5. 表单输入字段验证模式
- 6. 将值添加到输入字段中
- 7. 将数据添加到输入字段
- 8. nodejs表单模块:如何将字段添加到字段中
- 9. 如何通过jQuery将表单输入字段添加到主字段?
- 10. 将新字段添加到Bond模式
- 11. 将隐藏字段添加到表单
- 12. 添加id来MVC表单输入
- 13. 如何动态添加输入字段到表单
- 14. 添加输入字段到一个HTML表单
- 15. 如何动态添加输入字段到表单?
- 16. Access 2000自动添加文本到表单输入字段
- 17. 将字段添加到django中的模型表单
- 18. 将自定义类型添加到角度模式形式 - datepicker
- 19. 将id属性添加到html输入
- 20. 如何将id添加到输入中?
- 21. 添加外部输入到角度模块
- 22. 使用JQuery更改动态添加的表单字段的输入ID
- 23. 向产品插入表单添加新的输入字段Opencart
- 24. 将推荐列表动态添加到输入字段
- 25. 将输入字段添加到HTML表单中的JavaScript函数不清
- 26. 如何将输入字段添加到使用Javascript的表单中?
- 27. 角度文本输入将重复值添加到重复的文本输入
- 28. django将ManyToMany字段/表添加到现有模式,related_name错误
- 29. 针对特定的文本输入到表单输入字段并添加样式到它?
- 30. 将下拉式输入添加到搜索表单中