ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Modifying forms field value before saving to DB

abiglietti@gmail.com 09 Jan, 2021
Hi,

In a form I have a textarea that the user can write using also carriage return but I need to save thew textarea in the DB without CR.

In the action panel of the form I have prepared a "Custom Code" action before the "Save data" action with the following code:

<?php
$str = $_POST['lc_field1'];
$str = str_replace(array("\n","\r"), "§", $str);
// following string is just to verify if the carriage return is changed in something else and it is.
document.print($str);
// here I need to use something like {'lc_field1'} = $str but I was unable to find in Internet a PHP statement that can do what I need.
?>

Please note that lc_field1 is the name of the textarea field in the form and also the name of the column in MySqli DB.

Is there someone that can help me? Thanks
Andrea
Max_admin 15 Jan, 2021
Answer
Hi Andrea,

Which Chronoforms version is this ? try to use:
$this->data["lc_field1"] = $str;
for v6 & v7
but for v5 you will need to replace $this by $form
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
You need to login to be able to post a reply.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com