In XForms, how to make all the fields readonly, except few fields?

给你一囗甜甜゛ 提交于 2020-01-15 03:51:07

问题


I did the following to make a full page read-only, using Making an Entire Instance Read-Only:

<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?


回答1:


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.

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()"/>


来源:https://stackoverflow.com/questions/8079818/in-xforms-how-to-make-all-the-fields-readonly-except-few-fields

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!