enketo-core
enketo-core copied to clipboard
readonly should be dynamic
But do not rush to implement this as it has never been requested.
It has now been requested (for Survey123).
One way to implement this is to add to evaluation cascade and use evaluation result to set the readonly boolean attribute on the original form control. The expression would be stored in the data-readonly attribute during XSL transformation.
- [ ] in enketo-xslt copy readonly expression to
data-readonlyattribute (like relevant, calculate, required) and do not set thereadonlyattribute. - [ ] in enketo-core add to evaluation cascade and set
readonlyatttribute - [ ] in widgets-controller (or elsewhere), do an additional check whenever calling the widget enable function as the question has to 1) be relevant and 2) not be readonly
- [x] turn the
readonlyproperty fromget props()in the Widget super class to a getter function - [ ] check all
props.readonlyusage in all widgets to remove assumptions that this condition is static
minor comment (and so that I'll get pinged on future updates) that the readonly binding doesn't appear to get evaluated as an XPath expression per se, rather just a static check to see if the string is "true()" or not (case insensitive?). Perhaps initially evaluating this (once) using XPath processor instead could be an easier initial step forward?
Yes, that would be a good first step. Thanks!
This is a feature would also be nice for us