Special Characters X PHP Code - SOLVED

HyperOsmar

Member
Dear Colleagues,
I'm migrating (in testing phase) from Joomla 3.X to 4.X...
In the previous version there was a plugin for validating Special Characters of elements and, which worked perfectly, this plugin is no longer present in the current version.
I'm trying to replace it with the PHP Code plugin, inserting the following rule:

$value = "{cad_municipios___observations:value}";
if (strpos($value, ';') !== false) {
$value = str_replace(';', '|', $value);
JFactory::getApplication()->enqueueMessage("The character ';' has been replaced by '|'.", 'warning');
"{cad_municipios___observacoes} = '$value'";
}​

But unfortunately, without success...
Can someone help me???...
 
Joomla - 3.9.28
Fabrik - 3.9.2
MySQL - 5.7.23
PHP - 7.4.16

Agora estou migrando para um servidor de teste:
Joomla - 4.3.1
Fabrik - 4.0gamma3
MariaDB - 10.4.25
PHP - 8.1.10

In version 3.X, the plugin worked perfectly... as shown in the image below:

upload_2023-6-22_12-2-7.png
 
Last edited:
Ok.
You should be able to use the regex validation or php validation (but with valid php code)
http://fabrikar.com/forums/index.php?wiki/regular-expression-validation/
http://fabrikar.com/forums/index.php?wiki/php-validation/
Something like (I didn't test)
php with replace=yes
Code:
if (strpos($data, ';') !== false) {
$value = str_replace(';', '|', $value);
Joomla\CMS\Factory::getApplication()->enqueueMessage("The character ';' has been replaced by '|'.", 'warning');
return $value;
}

Maybe the specialchars validation will make it into the next release.
 
Last edited:
Where am I going wrong???...
upload_2023-6-22_14-46-40.png


Anything I type validation fails...
upload_2023-6-22_14-45-16.png


In MySQL it does not save...
upload_2023-6-22_14-49-27.png
 
Last edited:
I missed to replace $data in str_replace. So
Code:
if (strpos($data, ';') !== false) {
$value = str_replace(';', '|', $data);
Joomla\CMS\Factory::getApplication()->enqueueMessage("The character ';' has been replaced by '|'.", 'warning');
return $value;
}
else return $data;
should do.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top