how to post error message after submit.

3shian 08 May, 2011
hi guys..

my question is all about the message after the submit event.. for exam in my case i have a student registration, where in my form i have this input box named as student no.. all i want to do is for example someone will put a student number but the student number is already taken or invalid, i want to post an error to the user that the student number in invalid or already taken..

please help me guys.. BTW chronoform rocks!!!!
GreyHead 08 May, 2011
Hi 3shian,

This is a case for the Custom ServerSide Validation action. There a code example here

Bob
3shian 09 May, 2011
sir i have follow some thing interms of using the server side validation but my problem now is when i submit an error occure.. im lost i dont know what to do next.. i will post the screen shot of my settings.. please help me..[attachment=2]form layout.JPG[/attachment][attachment=1]event settings.JPG[/attachment][attachment=0]event loop setting.JPG[/attachment]
3shian 09 May, 2011
heres the following settings and the error that occure![attachment=1]validation setting.JPG[/attachment][attachment=0]after bubmit.JPG[/attachment]
GreyHead 09 May, 2011
Hi 3shian,

It looks as though you have the Validation OnFail Event Loop set up to trigger the Validation OnFail Event which, of course, triggers the Validation OnFail Event Loop which in turn triggers the Validation OnFail Event Loop, . . . until you hit a limit.

Leave the OnFail Event Loop setting as On Load to re-display the form.

Bob
3shian 09 May, 2011
hi sir.
thank you so much for the response.. i have done what you have said.. I set it on the >On Load setting.. it works good when i try putting an existing student number.

the thing now is when i try to put a student number that doesn't exist yet, it also says it already exist.. what should i do sir? thanks alot!
GreyHead 09 May, 2011
Hi 3shian ,

The only validation that I see in your image is that the Student Number is required. So the test will only fail if the input is left empty,

You'll need to add custom server side validation to check if the Number is already in use.

Bob
3shian 09 May, 2011
thanks for the response sir..

my problem now i dont have yet any idea how to do manual coding for custom server validation..

can you give me any hint for my situation sir? thanks alot in advance.
GreyHead 09 May, 2011
Hi 3shian,

I'm afraid that you are going to need help from someone with more coding/Joomla! experience.

If you try some code we may be able to help you debug it. It just isn't possible to write code for you or other users right from the beginning.

Bob
3shian 09 May, 2011
ok sir ill try my best to figure this problem.. ill just need more time for the coding.. when i figure it out ill post in this forum so that it can help someone.. thanks alot sir..
3shian 14 May, 2011
ok sir heres my first trial code for custom server side validation.. ok same as the last time it detects the existing student no. but the problem when i put a non existing student no. it also post the error and the data is not save in the database..i think the problem is all about the event loop that is set at >On Load event.. is there any way to do this validation?
thanks in advance...
<?php
$table = 'ced_student_profile';
$test = mysql_query("SELECT studentno FROM $table WHERE studentno = 'studentno'");
if ( $test ) {
  $form->validation_errors['studentno'] = "already exist.";
  return false;
}
?>
GreyHead 14 May, 2011
Hi 3shian,

The problem is not with the Event Loop. As far as I can see the code you posted does nothing useful unless there is more than this snippet.

Here's a revised version that might help. You'll still need to amend it to work with your form.
<?php
$studentno = JRequest::getInt('studentno', '', 'post');
if ( !$studentno ) {
  $form->validation_errors['studentno'] = "You must enter a student number";
  return false;
}
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__student_profile`
        WHERE `studentno` = '' ;
";
$db->setQuery($query);
$test = $db->loadResult();
if ( $test ) {
  $form->validation_errors['studentno'] = "already exist.";
  return false;
}
?>


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