WebsiteBaker Community Forum

WebsiteBaker Support (2.13.x) => Modules => Topic started by: netraam on January 18, 2023, 09:41:39 PM

Title: Mpform with smileys and emojis
Post by: netraam on January 18, 2023, 09:41:39 PM
Hello,

i'm using Mpform for several years. now I have version 1.3.22.
Tha last couple of years the people are using more and more smileys and emojis.
But when they send a form with a emojis Mpform can't save it to the database it just sends me an email.
Is there a simple solution for this? I dont mind if the smiley disapear I just want it to save the form in the database.

thanks in advance
Maarten
Title: Re: Mpform with smileys and emojis
Post by: sternchen8875 on January 19, 2023, 01:08:47 AM
what is the collation for the mpform-database-tables? Emoji's need utf8mb4. Maybe, thats the solution, but i've never use emoji's in a formular
Title: Re: Mpform with smileys and emojis
Post by: hgs on January 19, 2023, 07:35:22 AM
The current version of mpForm is  1.3.43  and available for download here (https://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?download=0A702411)


But the current versions are also adapted to the current php version (https://www.php.net/supported-versions.php) and the current WebsiteBaker (https://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?download=0E15BDB5) Version
Title: Re: Mpform with smileys and emojis
Post by: Martin Hecht on January 27, 2023, 10:20:45 PM
Is the problem still there, when you swith to the latest version of mpform? Can it be solved by converting the database tables? (make a backup before running experiments...)
Title: Re: Mpform with smileys and emojis
Post by: netraam on February 07, 2023, 04:02:45 PM
In the meantime i found a solution.
I've added a section to the page of the mpform.
The extra section is a code module where i've wrote a script that remove all Non-ASCII characters from my large textfield (in my case field #7).
The script is executed when you click on the send button.

Code: [Select]
echo "<script>
$('.mpform_submit').on('click', function () {
  removeInvalidChars();
});

function removeInvalidChars() {
  var str = $('#field7').val();
  str = str.replace(/[^\x20-\x7E]/g, '');
  $('#field7').val(str);
}
</script>";