我希望有人能给我一个提示。Ic创建了一个具有不同数组字段的表单。其中一个有两个下拉列表,第二个下拉列表中的条目取决于第一个条目的选择。THis应该很容易用观察者求解,在第一个值的选择发生变化后,只需加载第二个值即可。到目前为止,没有问题。
但现在的问题是,如果我测试静态字段集,这很容易,但我不知道如何处理动态添加的字段的观察者。
此外,我不确定是否有一个选项来处理相对字段而不是绝对字段。这会容易得多,因为我必须始终在实际对象中设置值。
这是一个小的小提琴设置https://jsfiddle.net/ygwuxrbk/
{
"schema": {
"title": "Erfassung",
"type": "array",
"items": {
"title": "Account",
"type": "object",
"properties": {
"services": {
"type": "array",
"title": "Services",
"required": true,
"uniqueItems": true,
"items": {
"description": "Angebotenen Services des Anbieters",
"type": "object",
"id": "arr_item",
"properties": {
"category": {
"type": "select",
"title": "Service Kategorie",
"required": true,
"$ref": "#/definitions/categories"
},
"service": {
"title": "Service",
"type": "select",
"enum": service["Beauty & Wellness"]
}
}
}
}
}
},
"definitions": {
"categories": {
"enum":
categories
},
}
},
"options": {
"fields": {
"category": {
"type": "select",
"label": "Category",
"onFieldChange": function (e) {
console.log(this.getValue());
}
}
}
},
"form": {
"attributes": {
"action": "http://testcompany.com/echo.php",
"method": "post"
},
"buttons": {
"save": {
"title": "Save",
"click": function(e) {
alert(JSON.stringify(this.getValue()));
//this.submit(); // submit it via regular HTTP post
this.ajaxSubmit(); // submit via ajax
}
}
}
}
}发布于 2017-10-18 21:18:32
上面示例中使用的路径是
"options": {
"items": {
"fields": {
"services": {
"items": {
"fields": {
"category": {
"events": {
"change": function() {
console.log(this.value);
}
}
}
}
}
}
}
}https://stackoverflow.com/questions/46785954
复制相似问题