Server Side Validation issue

mattiadj 19 Dec, 2011
Hello to all,
with this latest version of CF i don't have understand how can i insert a custom server side validation!
If i put in on submit event "custom server side valdation" and in it i insert


<?php
$error_count = 0;
if ( $form->data['ruolo'] == '' ) {
  $form->validation_errors['ruolo'] = "Devi inserire il tuo titolo";
  $error_count++;
}



if ( $error_count ) {
  return false;
}
?>


Nothing happens!

I attach the scheme of my actions and events...
How can i fix it?
GreyHead 19 Dec, 2011
Hi mattiadj,

Please drag an Event Loop action into the pink On Fail event box of the Serverside validation action.

Bob
mattiadj 19 Dec, 2011
Ok,
then?and...why this??🙂 This CF is quite difficult than v3...😟

Edit:made it but now apache crashes!!
Setting attached as img
GreyHead 19 Dec, 2011
Hi mattiadj ,

Yes . . . and it's midnight here. I'll be back in the morning.

Bob
mattiadj 19 Dec, 2011
Is midnight also here...i'm from italy🙂
I'll see you back tomorrow🙂
GreyHead 20 Dec, 2011
Hi mattiadj,

Back again,

The Event Loops should be set to the defafult > On Load so that they loop to the OnLoad event. (I suspect that you have them set to > On Submit which causes a loop and cracshes the site.

Also you should probably drag the Validation action before the Upload Files action.

Bob
mattiadj 20 Dec, 2011
Ok now works but i don't understand why... when i have to use eventloop?and when i have to set to onsubmit or onload?

Also, in all part of form i have used this code to load the page


<?php 
$path = JPATH_SITE;
require $path.'/form/preventivo/nameOfFile.ext';?>


but now for the Server side validation it doesn't work. Since is a heavy validation is much easy for me to make an external file to manage...how can i do?
GreyHead 20 Dec, 2011
Hi mattiadj,

The Event Loop action loads an Event. You set it to the Event you want to load. Most of the time it's used - as it is here - to reload the form by calling the On Load event.

Your require code should work OK for ServerSide validation :-(

I ran a test and it looks as though the return false; doesn't work from the included file. I got it working like this. In the Serverside validation action:
<?php
include (JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'includes'.DS.'test_form_multi_validation'.DS.'serverside_validation.php');
if ( !$return ) {
  return false;
}
?>

In the included file:
<?php
/* ensuring that this file is called up from another file */
defined('_JEXEC') or die('Restricted access');

$input_text_0 = JRequest::getVar('input_text_0', 'empty', 'post');
if ( $input_text_0 ) {
  $form->validation_errors['input_text_0'] = "Text input was : ".$input_text_0;
  $return = false;
}
?>
NB This validation is intended to fail, for testing purposes only!!

Bob
mattiadj 20 Dec, 2011
Thanks Bob,
i will try but now i have problem with upload files...can you check my new post and help me?

Thanks...
This topic is locked and no more replies can be posted.