Here's a dummy example :
<xf:bind id="test-bind" name="test" ref="test" relevant="true()">
<xf:constraint level="warning" value="false()"/>
</xf:bind>
<xf:bind id="field1-bind" name="field1" ref="field1"
calculate="xxf:evaluate-bind-property('test-bind','relevant')"/>
<xf:bind id="field2-bind" name="field2" ref="field2"
calculate="xxf:evaluate-bind-property('test-bind','constraint')"/>
I expect the value of field1 to be 'true' (which is) and value of field2 to be 'false' (which is not !). Actually both are evaluated to 'true'. If I define the xf:constraint with no level, I got the 'right' behavior. It looks like a constraint with a level='warning' is not a 'real' constraint... Is this normal ?
And if yes, then how to get the result of the "warning validation" (aka: for example defining conditionnal action with condition depends on the warnings being activated or not) ? Can't use the valid() function neither as the warning level is not in the scope of the valid() function...
As of 4.7, xxf:evaluate-bind-property()
indeed only gives you access to the error-level constraints, and there is even a "TODO" in the code about this ;).
I don't know if this could work for you, but another way to deal with this would be to rely on events, as the error summary does. Specifically, you could listen for the xxforms-constraints-changed
event, which comes from controls in the view, and then get the constraint level with event('level')
. You can see how this is done in the error summary code.