在XForms 中,如何将所有字段设为只读,少数字段除外? [英] In XForms, how to make all the fields readonly, except few fields?

查看:49
本文介绍了在XForms 中,如何将所有字段设为只读,少数字段除外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 使整个实例只读:

<xforms:instance>
    <form>
        ...
    </form>
</xforms:instance>
<xforms:bind ref="instance('form-name')" readonly="true()"/>

但我要求只启用几个字段.我尝试了这样一个为 多个绑定在给定节点,但用于属性必需".所以这失败了.

But I have a requirement to enable just few fields. I tried such a code that was given for Multiple binds on a given node but was for the property "required". So this fails.

<xforms:bind ref="instance('form-name')/some-node" readonly="false()"/>

那么,是否可以单独为几个节点覆盖表单实例的全局只读设置?

So, is there away to override the global read-only setting for the form instance for a few nodes alone?

推荐答案

正如您所指出的,使用 readonly="false()" 的绑定无效,因为这是默认设置,并且根据管理 给定节点上的多重绑定.

As you noted, a bind with readonly="false()" has no effect, since this is the default, and it won't override another bind saying that this node is readonly, per the rules governing multiple binds on a given node.

但是,您可以编写一个绑定,使实例中的所有叶元素(即不包含任何其他元素的元素:///*[empty(*)])读取-only,特定元素除外.例如:

However, you can write a single bind that makes all the leaf elements in your instance (i.e. elements that don't contain any other element: //*[empty(*)]) read-only, except specific elements. For instance:

<xforms:bind ref="//*[empty(*)] except (/some/node, /some/other/node, …)"
             readonly="true()"/>

这篇关于在XForms 中,如何将所有字段设为只读,少数字段除外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆