_webform_client_form_rule_check() is used to determine whether a component should be included in the client form. It involves evaluating conditionals on the component, its parent(s) and its pagebreak (if any). This is the same logic that WebformConditionals::executeConditionals applies to the submission data.
The conditionals need to be executed on the submission data before that data can be used to determine whether components should be included. But during their execution, the components to be includes will already be known. Accordingly, it should be possible to greatly simplify the code to conditionally include components in the client form.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | webform-hidden_on_submission-2454277-7.patch | 1.36 KB | danchadwick |
| #1 | webform-rule_check-2454277-1.patch | 21.14 KB | danchadwick |
Comments
Comment #1
danchadwick commentedThis patch enhances WebformConditionals::executeConditionals() to also keep track of the visibility of the components on each page. This data is store and later used to determine whether a component should be shown or not (WebformConditionals::componentVisibliity), or whether the whole page should be show (WebformConditionals::pageVisibility).
It retains the trinary distinctions of a) always shown, b) always hidden, and c) currently hidden, but on same page as a source, should should be included on the page and hidden by javascript.
Using WebformConditionals greatly simplifies and unifies the code for checking whether a component should be included on a page. As a side benefit, it also greatly simplifies the code that handles Prev/Next page, including skipping empty pages, always showing page 1 and always showing the preview page (if selected).
This patch must be applied after #1815996: Multiple target components for each conditional.
Comment #3
danchadwick commentedDarn testbot.
Comment #4
danchadwick commentedCommitted to 7.x-4.x.
Comment #6
danchadwick commentedPatch to be ported to D8. Of the four conditional patches, apply 2nd.
Comment #8
danchadwick commentedRegression. When deciding whether to display nested components in a submission (rather than a form), components which are currently hidden but are needed for the form because they might be displayed by a same-page conditonal are incorrectly displayed on the submission. The form is submitted -- it is now clear that they should be hidden.
Committed to 7.x-4.x
Comment #9
danchadwick commentedPatch to be ported to D8. Of the four conditional patches, apply 6th.
Comment #10
fenstrat#5 committed and pushed to 8.x-4.x.
Comment #13
fenstratCommitted and pushed #7 to 8.x-4.x. Thanks!