I have a form where block visibility is based on a checkbox value. The checkbox value is set as part of the prefill service.
However, if I examine the form elements using browser tools, the checkbox value = true, but the block is not visible.
The block(s) are removed, then added based on prefill data, so I wonder if that is interfering with the rule.
The visibility rule is set to trigger at initialisation, so I expect that the rule should work.
The rule for each block is simple:
any ideas of how to trouble shoot this issue?
thanks for the feedback.
Yes, I've used dev tools to interrogate the rule and the console shows "checkbox_x : true" and the form xml elements also show true (see screenshot). But the block is not visible.
However, the prefill is a bit more involved. the prefill removes the node and replaces it with a new node taht contains values for the checkbox and others (shown in screenshot).
Is it possible that may interfere with the visibility rule? When does the rule run in relation to prefill?
I'm not sure what else to do to trouble shoot this.
I have tested this functionality in a Composer form and have different results...
Form Prefill service:
Visibility rule in Composer (including dependencies and type):
This code works as expected, using both "true" and "false" prefill values.
Have you tried using console.log() in the Visibility Rule to print out the value of "checkbox_x"?