Validation Message in Event Switcher

Display a custom validation error message in ChronoForms v5.

Overview

The issue occurs because the method to set validation errors directly in the form object is not functional in CF v5.
Use the 'Display Message' action within the 'On fail' trigger of the Event Switcher to show the error message.

Answered
Jo JohnVosDev 19 Oct, 2015
I have made a simple validation within the Event Switch code.
If the amount is less than 5 I want to display an error message.
I have coded:

if ( $amount < 5 ) {
$form->validation_errors['Bedrag'] = "Foutief Bedrag";
return "fail";
}

The validation is executed correct because of the status 'fail' and the executing of the 'on fail' functions (Event Loop - Load), but the error message is not displayed.
I think the code $form->validation_errors['Bedrag'] = "Foutief Bedrag"; will not work in Chronoforms V5.
Helas I can't find another method.

Thanks for helping.
se seagul 20 Oct, 2015
Answer
Hi,

just read your post as I was interested🙂

Did you try "Display Message" in the "On fail" trigger?
There you can also access your $form->data values.

Best
Seagul
Jo JohnVosDev 20 Oct, 2015
Thank you Seagul.
It works!
Sometimes you don't see the obvious solution.

In the meantime I found out an other soulution:

$app = \JFactory::getApplication();
$app->enqueueMessage('Foutief Bedrag. SVP minimaal 5 euro doneren.');
This topic is locked and no more replies can be posted.