Mar 28th, 2015, 5:29 AM
Apologies for replying to my own post - it's not nice but I've used a workaround that may be of interest to some.
I created a rule in the Hooks Manager module on "ft_update, sumbission, end". In the PHP code box I added the following:
What the code does is go through all the text fields of the form, the names of which I have included in $haystack, look for backslashes (\), single quotes (') or double quotes, which upon submission have been changed by formtools to (\\), (\") and (\') and replace them with the forward slashes (/) or " ` " signs.
Thus, the phrase "Smith's restaurant\bar" would be transformed to "Smith`s restaurant/bar".
It is not an elegant solution and not what I was after in the first place (which was to retain the users' input) but for the moment is OKish.
I hope that helps!
G.
I created a rule in the Hooks Manager module on "ft_update, sumbission, end". In the PHP code box I added the following:
PHP Code:
{
$haystack="FieldName1FieldName2FieldName3FieldNameetc";
foreach ($_POST as $key => $value)
{
if (strstr($haystack,$key))
{
$tmp = str_replace(array("\\'", "\\\""), "`", $value);
$_POST[$key] = str_replace(array("\\\\"), "/", $tmp);
}
}
}
What the code does is go through all the text fields of the form, the names of which I have included in $haystack, look for backslashes (\), single quotes (') or double quotes, which upon submission have been changed by formtools to (\\), (\") and (\') and replace them with the forward slashes (/) or " ` " signs.
Thus, the phrase "Smith's restaurant\bar" would be transformed to "Smith`s restaurant/bar".
It is not an elegant solution and not what I was after in the first place (which was to retain the users' input) but for the moment is OKish.
I hope that helps!
G.
(Mar 16th, 2015, 12:57 PM)garof Wrote: I have - I believe - a similar problem with apostrophes and quotes in the textbox input but with different results.
I have built a form to enter data from the label of products. Amonst the fields there is one for the brand name. In some cases, that amy include apostrophes, single or double quotes.
Unlike what the other users described, in my case the input doesn't get truncated but, instead, a backslash ("\") is placed before the apostrophe or the quotation mark. I understand that this may be part of the string sanitation that formtools performs. However, each time that an entry with a field containing an apostrophe or quotation mark is updated, an extra backslash is added.
So, for instance, the (hypothetical) brand name "Smith's" would be displayed as "Smith\'s". After another update of the entry that would become "Smith\\\'s" (which makes sense since the backslash needs shielding, too). Another update will lead to "Smith\\\\\\\'s, an so on.
I have verified that the input is saved as such in the database.
Is there any way to address that?
Thanks in advance for your time!
PS I am using FormTools v.2.2.6 and my form is a "Form builder" one.