[英]Alpaca ReadOnly after manual modification
I'm using Alpaca forms to display some information : 我正在使用羊驼毛形式显示一些信息:
$("#object_details").alpaca({
"schema": map[obj_type],
"data": JSON.stringify(json_data["content"]),
"options": {
"label": "some label"
}
})
So I have some JSON Schema defined : 所以我定义了一些JSON模式:
json_schema = {
"title": "Host",
"en_description": "Host object",
"type": "object",
"properties": {
"addr": {
"en_description": "IP addresses",
"title":"Host addresses",
"type": "object",
"properties": {
"ipv4": {
"en_description": "Host IPv4 address",
"title":"IPv4 address",
"type": "string",
"format": "ipv4",
"readonly":True
},
"ipv6" : {
"type": "string"
}
}
}
As you can see I got some field on ReadOnly, and some others on edit mode. 如您所见,我在ReadOnly上有一个字段,在编辑模式下有一些其他字段。 I want to make a modified-field to become readonly.
我想使修改后的字段变为只读。 For example, here, if I modify the ipv6 field, once I send my forms, the ipv6 field will become readonly.
例如,在这里,如果我修改ipv6字段,则在发送表单后,ipv6字段将变为只读。
Is that even possible ? 那有可能吗?
Yes you can do this by setting the read-only option to true after you submit the form like the following: 是的,您可以在提交表单后通过将只读选项设置为true来执行此操作,如下所示:
field.options.readonly = true;
field.refresh();
Here's a working fiddle for this.I hope this is what you're looking for, tell me if you need something else. 这是一个有用的小提琴 。我希望这是您要的东西,告诉我您是否还需要其他东西。 I'll be glad to help you out.
我很高兴为您提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.