_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.

Comments

danchadwick’s picture

Status: Active » Needs review
StatusFileSize
new21.14 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 1: webform-rule_check-2454277-1.patch, failed testing.

danchadwick’s picture

Status: Needs work » Needs review

Darn testbot.

danchadwick’s picture

Status: Needs review » Fixed

Committed to 7.x-4.x.

  • DanChadwick committed 297d6f6 on 7.x-4.x
    Issue #2454277 by DanChadwick: _webform_client_form_rule_check...
danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Fixed » Patch (to be ported)

Patch to be ported to D8. Of the four conditional patches, apply 2nd.

  • DanChadwick committed 840120a on 7.x-4.x
    Issue #2454277 by DanChadwick: Fixed conditionally-hidden components...
danchadwick’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Patch (to be ported) » Fixed
StatusFileSize
new1.36 KB

Regression. 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

danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Fixed » Patch (to be ported)

Patch to be ported to D8. Of the four conditional patches, apply 6th.

fenstrat’s picture

#5 committed and pushed to 8.x-4.x.

  • fenstrat committed 918f76a on 8.x-4.x
    Issue #2454277 by DanChadwick: Fixed conditionally-hidden components...
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Patch (to be ported) » Fixed

Committed and pushed #7 to 8.x-4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.