我想构建一个(部分)形式,它产生以下输出:
{
...
offers: {
context: "http://schema.org",
minPrice: 3
}
...
}
问题是,context
应始终存在 - 用户可以操作的唯一字段是minPrice
。马上就会想到一个有价值的隐藏场。所以这里是架构定义:
$scope.schema = {
...
offers: {
type: 'object',
properties: {
minPrice: {
type: 'number'
}
}
}
...
};
这里是表单定义:
$scope.form = [
...
{
key: 'offers',
type: 'fieldset',
items: [
{
key: 'offers.minPrice',
type: 'number'
},
{
key: 'offers.context',
type: 'hidden',
default: 'http://schema.org'
}
]
}
...
];
但是,观察生成的模型很明显,条目context
不存在。我已成功使用type: 'hidden'
和default
与tabarray
的组合,但我无法使用object
来解决问题。我正在使用0.8.13
的{{1}}版本 - 这是撰写本文时的最新版本。
感谢任何见解,谢谢。
答案 0 :(得分:0)
您必须在该版本的架构中包含上下文及其默认值。
我希望你的问题与应该已经在v1.0.0的alphas中修复的错误有关
它应该与:
一起使用<强>模式强>
{
"type": "object",
"properties": {
"offers": {
"type": "object",
"properties": {
"minPrice": {
"type": "number"
},
"context": {
"type": "string",
"default": "http://schema.org"
}
}
}
}
}
<强>表格强>
[
{
"type": "fieldset",
"items": [
{
"key": "offers.minPrice",
"type":"number"
},
{
"key": "offers.context",
"type": "hidden",
"notitle": true
}
]
}
]