Problem/Motivation
When using a token in a condition and the token cannot be replaced for whatever reason, the condition will use the name of the token (e.g. [my-random-token]). This is particularly problematic for users selecting the "Check if value is empty" option because such tokens will never evaluate to empty even if the corresponding field/attribute/etc. has no value. It is possible to work around this for certain fields by saying "[my-random-token] == [my-random-token]" instead of "[my-random-token] is empty," but that is unintuitive.
Proposed resolution
If no value is generated for a given token, replace it with an empty string. The core token replace method provides a simple "clear" option to achieve this.
Remaining tasks
Patch. Test. Discuss side effects.
User interface changes
Replace "@todo Add description" with a description of the "check if value is empty" behavior.
API changes
None
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | token_conditions-better_empty_evaluation-2974582-3.patch | 1.5 KB | manuel.adan |
| #2 | token_conditions-better_empty_evaluation-2974582-2.patch | 1.43 KB | ndewhurst |
Comments
Comment #2
ndewhurstHere is a patch that clears irreplaceable tokens instead of leaving their names in the strings. It applies to both the token string and the compared value string if applicable. I also added a description to the checkbox. Does this raise any concerns for other module users?
Comment #3
manuel.adanThe clear option in token replacement is certainly mandatory here. Patch didn't apply cleanly because of recent changes. Re-rolled with minor changes in the provided description text according to new field names. Thanks!
Comment #5
manuel.adan