Can't put text in a calculation markup field

Created on 27 November 2024, about 2 months ago

Problem/Motivation

If the field worked as described in the help text (":webform_element_key_1 + :webform_element_key_2 - (:webform_element_key_1 * :webform_element_key_3)" - wrapped in h3s) then I might expect this, but if you try and submit that it says you have to surround the math in double braces ("Failed to extract expression, make sure to round the expression between {{ }}. eg: {{ :field1 + :field2 }}"), which leads me to expect any text outside of the double braces would just be output.

Instead, it takes each word of my text and says they are fields that don't exist.

It's possible this is the same issue as πŸ“Œ Webform Calculation markup currently doesn't work with multiple expressions Needs work , but it happens even with a single calculation.

Steps to reproduce

Create a webform with a number field and a calculation markup field. In the markup field, do a basic calculation and add extra text, e.g. "Total is {{ :number|0 * 3 }}". Note that it gives an error (for the example, "The following field(s) (Total, is) does not exists on the webform. Please check your expression!").

Proposed resolution

Don't try to evaluate text outside of the braces, and just output it. Update the help text to indicate the use of braces is required.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada kpaxman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024