String .replace right parentheses Fails

======== TEMPLATE BUG FORM ========

Wappler Version : 4.0.1
Operating System : Windows 10
Server Model: LAMP
Database Type: MySQL
Hosting Type: private server

Expected behavior

What do you think should happen?

When we receive a form field in the form of a POST for a “phone number” we want to double check and remove any dashes and parentheses from the number before the value is inserted into the database. Using .replace as shown below:

{{$_POST.user_phone.replace('-', '').replace('(', '').replace(')', '')}}

we expect the following form value (123)-456-7890 to be inserted as 1234567890.

Actual behavior

What actually happens?

For the “dash” and “left parentheses” the replace works as expected. However, when the “right parentheses” is checked, it fails and the following is returned in the web Response:

file: "/home/CLIENT/public_html/CLIENTportal/dmxConnectLib/lib/formatters/text.php"
line: 92
message: "Too few arguments to function lib\\core\\formatter_replace(), 1 passed and exactly 3 expected"

How to reproduce

  • Create a simple form with an input field that will be passed to a server connect
  • Create a server connect and add a “Set Value” give it a name and make sure it is set to “Output”
  • Click the lightning bolt to assign the $_POST value from your form to the “Set Value” value
  • Click on the magic wand and add three “Replace String” items, one for a dash and one each for the left and right parentheses
  • Save your form and server connect action
  • Test with value: (123)-456-7890
  • Output will be displayed in the browser’s “Network” tab

Your server connect “Set Value” should look something like:

Extra Thoughts

When testing we broke out each .replace and had three different “Set Value” steps. By testing each one separately is how we were able to determine that the right parentheses is the one that fails to be replaced.

Seems there was a bug in the parser, please test the following update. Unzip file to dmxConnectLib/lib/core. (3.0 KB)


I can confirm that this has resolved the problem.

Thank you for looking into this.

This has been fixed in Wappler 4.0.6