Loading
task: #3457624: Add a README.md and document using :value tokens to avoid prefix and suffix in expressions
Closes #3457624
Adds a README.md to the module, following the drupal.org README.md template. The module had no README, and the :value token needed to calculate with prefixed or suffixed fields was not documented anywhere.
What the README covers
- Requirements (Token,
webit/eval-math), recommended modules (Devel), installation and configuration. - Field types, field settings and the "Always Evaluate Expression?" display setting, plus a note on the legacy Expression field type.
- Expression syntax: operators, built-in functions,
;separated statements, user-defined functions. - Tokens and token default values.
- "Use raw values in tokens": field tokens such as
[node:field_price]return the formatted value (prefix, suffix, thousand separator), which evaluates to0;[node:field_price:value]returns the stored number. - Troubleshooting for a field that is always
0, and for values that do not follow changes in referenced entities.
Testing
The token examples were checked on 2.x-dev with Drupal 11 and Token 8.x-1.17, using a decimal field with prefix $ and suffix kg and the value 1234.5:
| Expression | After token replacement | Result |
|---|---|---|
[node:field_price] * 2 |
$1234.50 kg * 2 |
0 |
[node:field_price:value] * 2 |
1234.5 * 2 |
2469 |
[node:field_product:entity:field_price:value] * 2 |
1234.50 * 2 |
2469 |
Notes
- Documentation only; no code changes.
- Tamper integration and automatic stripping of non-numeric characters were considered and left out; see the issue summary for the reasoning.