I've developed a chronoforms v5 (in a Joomla 3.4.8 site) and I need to add a custom server-side validation on an input text field. Simply I need to check that the input filed name "codiceConvenzione" has one oh three values (es: valueA, or valueB, or valueC).
Following this link: http://www.chronoengine.com/faqs/54-cfv4/cfv4-validation/2592-how-do-i-use-custom-serverside-validation.html
I've added the following "custom code" element into the onSubmit ChronoForms action:
<?php
$ok_values = array(
'valueA',
'valueB',
'valueC'
);
if ( !in_array($form->data['codiceConvenzione'], $ok_values) ) {
$form->validation_errors['codiceConvenzione'] = "The Convention code isn't valid";
return false;
}
?>
Unfortunately, as reported in link http://www.chronoengine.com/faqs/54-cfv4/cfv4-validation/2592-how-do-i-use-custom-serverside-validation.html, this solution isn't valid for Chronoforms v5 (is for ChronoForms v4).
Has anybody created a custom PHP validation in Chronoforms v5? Could you please show me your PHP code and where you have put it?
You've probably already found a solution, but I answer you because it might be useful to other people.
ChronoForms v5 doesn't have a Custom Serverside validation action, You can use an Event Switcher action to add custom serverside validation, however that does not offer the same methods to show errors. See here: https://www.chronoengine.com/faqs/70-cfv5/5212-event-switcher.html
Basically to convert your validation, you need to add an Event Switcher with the following code:
Then add an Event Loop in the fail event of the Event Switcher. As you can see in Chronoforms V5 the error array has changed name in
$form->errors['input_name']