Token name sent instead of value, if value is zero (0)

Created on 6 February 2024, 10 months ago
Updated 17 May 2024, 6 months ago

Problem/Motivation

We are seeing the token names being sent to a remote REST service, when a value from the webform submission is zero. In this particular webform's case, zero values are valid and should be sent to the remote service -- however, they are getting stripped out in the _webform_remote_handlers_token_cleaner() function.

Steps to reproduce

Create a webform that sends a value of zero. For example, a "Radios" element with several values, and one of them 0.

Configure the REST handler, with a message that includes the field's value as a token -- for example,

{ 	
  "sid": "[webform_submission:sid]", 
  "id": "iq_survey_alt_version",
   "participant" : "[webform_submission:values:participant]", 
"Section": 
[
{ "Question": "4", "Answer":
 "[webform_submission:values:4_how_many_servings_of_fruit_]"
}
]
}

If the value for [webform_submission:values:4_how_many_servings_of_fruit_] evaluates to "0", the payload sent to the REST server sends
"[webform_submission:values:4_how_many_servings_of_fruit_]" instead of "0".

Proposed resolution

Allow "0" values to get sent using the handler.

Remaining tasks

Fix the _webform_remote_handlers_token_cleaner() function, which checks each value with the PHP empty() function, and change it to not replace zeros.

User interface changes

None.

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

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