Hi,
I used event switcher to validate input in a v4 form. Now I want to do the same in a v5 form.
I dragged an event switcher into the submit action, adapted some php code from v4 into it and loaded the events "true" and "false", added an event loop into the "false" switch. This looks quite similar to what I made once in v4.
Unfortunately when testing the form by submitting it with empty fields, no warning with error message appeared, and an empty record was saved to db. I have no idea what went wrong.
The code for validation looks like this:
Thanks for any help!
Regards,
Herbert
I used event switcher to validate input in a v4 form. Now I want to do the same in a v5 form.
I dragged an event switcher into the submit action, adapted some php code from v4 into it and loaded the events "true" and "false", added an event loop into the "false" switch. This looks quite similar to what I made once in v4.
Unfortunately when testing the form by submitting it with empty fields, no warning with error message appeared, and an empty record was saved to db. I have no idea what went wrong.
The code for validation looks like this:
<?php
//Check first name
$valid = true;
$vnm=ucwords(strtolower(substr(trim(strip_tags(JRequest::getString('vnm', '', 'post'))),0,30)));
if (!$vnm) {
$form->validation_errors['vnm'] = "Bitte geben Sie Ihren Vornamen an.";
$valid=false;
}
else $form->data['vnm']=$vnm;
etc with some more fields…
return $valid;
?>
Thanks for any help!
Regards,
Herbert