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
- The webform conditional tab will be enhanced so that each rule row has a
(+)button in addition to the+and-buttons. - Adding a sub-conditional adds an open parenthesis row, two new rule rows, and a close parenthesis row. Indentation indicates the nesting level.
- Removing the last rule within a sub-conditional removes the open and closing parenthesis rows which indicate the sub-conditional.
- Removing an open or close parenthesis row will remove the matching row, but not the contained rules. The contained rules will simply be outdented.
- Deleting a component will adjust the sub-conditional as if the rules that reference the component were deleted via the UI.
- The conditional execution code in the server will be enhanced to supported nested sub-conditionals.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | webform-subconditionals-2757751-2.patch | 50.19 KB | danchadwick |
Comments
Comment #3
danchadwick commentedCommitted to 7.x-4.x.
Needs port to D8.
Comment #4
danchadwick commentedComment #5
danchadwick commentedComment #6
danchadwick commentedComment #7
danchadwick commentedComment #8
fenstratClosing 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.