While digging around the same-page conditional code I came to wonder what was the meaning of the (undocumented) existingValue argument for the JS-comparison handlers.
It seems they are needed for rule groups that span multiple form pages. Example:
- page1 (1 component): one
- page2 (2 components): two, one & two (depending on both one and two).
With the current code on page2 the full conditional group is put into the settings. Because the form element for one is not present on page2 its value is passed in the settings and then passed to the comparson callback as existingValue.
I think this could be simplified easily by evaluating the comparison callbacks for components from earlier pages on the server side. This would remove a pitfall from implementing new comparison operators and conditional types.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3005884-conditionals-remove-existingValue-2.patch | 12.98 KB | torotil |
Comments
Comment #2
torotil commentedHere is a simple implementation of this idea. These are the changes made:
WebformConditionals::executeComparison().source_typefor JS evaluation that simply provides the evaluated value.webform_conditional_prepare_javascript()render a “result” rule instead.existingValueargument. Comparison operators are guaranteed to only be invoked on the same page as their element.In an ideal world we could even make further calculations on the server-side to eliminate the already evaluated rules (and possibly some others as well).
Comment #3
torotil commentedNote that I didn’t remove the
existingValueparameter to keep API-compatibility.Comment #4
torotil commentedComment #5
torotil commentedComment #6
liam morlandAt this point in the D7 life cycle, I wonder about the value of a big change like this.
Comment #7
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.