In XForms, how to make all the fields readonly, ex

2019-07-08 02:44发布

问题:

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


标签: orbeon xforms