Problem/Motivation

Currently, webform can calculate a series of individual conditional rules and combine them with an and or or operator. For example, A and B and C and D or for example A or B or C. Sometimes this isn't sufficient to express the needs for a particular webform. For example, one might want A or (B and C).

Proposed resolution

This issue proposes to add nested "sub-conditionals", which correspond to the parentheses in the above example. Each sub-conditional can have its own and versus or operator. Sub-conditionals may be nested.

Remaining tasks

None.

User interface changes

  1. The webform conditional tab will be enhanced so that each rule row has a (+) button in addition to the + and - buttons.
  2. Adding a sub-conditional adds an open parenthesis row, two new rule rows, and a close parenthesis row. Indentation indicates the nesting level.
  3. Removing the last rule within a sub-conditional removes the open and closing parenthesis rows which indicate the sub-conditional.
  4. Removing an open or close parenthesis row will remove the matching row, but not the contained rules. The contained rules will simply be outdented.
  5. Deleting a component will adjust the sub-conditional as if the rules that reference the component were deleted via the UI.
  6. The conditional execution code in the server will be enhanced to supported nested sub-conditionals.
  7. The conditional execution code in the browser (for intra-page conditionals) will be enhanced correspondingly.

API changes

None.

Data model changes

None. The nested sub-conditionals will be stored in the database as rules. Normal (existing) rules have a source_type of "component". Sub-conditionals will be indicated with "conditional_start" and "conditional_end".

Any webform-related modules which read or use the webform conditional rules should already be checking for a source_type of "component". It is not clear if there are any modules which do so.

Theme changes

The CSS and HTML for the conditionals tab has changed slightly. Since normally only administrators or webform creators use this page, any impact on themes is expected to be very slight.

Related bug fix

As part of the implementation of this feature, a bug which incorrectly added all new rules or actions at the end of all the rules or actions was fixed.

Sponsorship

This feature was sponsored by the nice folks at PreviousNext for the Brisbane City Council in Australia.

Comments

DanChadwick created an issue. See original summary.

danchadwick’s picture

StatusFileSize
new50.19 KB

Committed to 7.x-4.x.

Needs port to D8.

danchadwick’s picture

Status: Active » Fixed
danchadwick’s picture

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

Assigned: danchadwick » Unassigned
danchadwick’s picture

Category: Feature request » Task
fenstrat’s picture

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

Closing to clear out the old Webform 8.x-4.x branch. See #2827845: [roadmap] YAML Form 8.x-1.x to Webform 8.x-5.x.

  • DanChadwick authored 91617e8 on 8.x-5.x
    Issue #2757751 by DanChadwick, PreviousNext: Sub-conditional and/or...

Status: Fixed » Closed (fixed)

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