Forums

Multiple server-side validation?

jenstechs 30 Aug, 2009
Hi,

I'd like to run some php for server-side validation. I can get it to run, I can get it to verify correctly, I can get it to repopulate just fine.

But all it does is show one message in the red box with a #1 by it, and that's only when I "return $message". How do I get:

1. The error list-style to go away so I can format my own list, or
2. The existing structure to take in an array of error messages so it will output them in the red error box list styles?

Thanks...
GreyHead 01 Sep, 2009
Hi jenstechs,

You can either (a) add the error messages into a singe message and return that:
<?php
$errors = array();
if ( validation 1 ) {
  $errors[] = 'Error message 1';
}
if ( validation 2) {
  $errors[] = 'Error message 2';
}
. . .
if ( count($errors) ) { 
  $errors = implode('<br />', $errors);
  return $errors;
}
or (b) you coudl use Joomla $mainframe->enqueuemessage('message', 'error'); to return your messages provided that your template supports the display of system messages.

Bob
jenstechs 01 Sep, 2009
If I use an array separated by BRs, it's still going to appear in the red box as a single list, right? They're all going to appear under #1. Ideally I'd like to be able to add the messages as #2, 3, 4... Do you think if I pass it just the array, it would understand to parse that as the list? In other words, I'm sure the system code knows how to product multiple LIs, I just need to find out how it's done.

I will also try the joomla mainframe error. I would just pass that as php code for each message? But then probably each message would be in a separate box...
GreyHead 01 Sep, 2009
Hi jenstechs,

I'm fairly certain that the ChronoForms code won't parse an array in the return message. It might be possible to add entries directly to the ChronoForms error array. You'd need to dig for the code though.

Bob
jenstechs 01 Sep, 2009
That's what I was worried about. It would be extremely beneficial if the code would parse an array... I wonder where in the codebase I'd look for that??
GreyHead 01 Sep, 2009
Hi jenstech,

Components/com_chronocontact/libraries/chronform.php function checkServerValidation() around line 252 - includes the line $MyForm->addErrorMsg($returnval);

Bob
jenstechs 01 Sep, 2009
Thanks!! I will check that out...
This topic is locked and no more replies can be posted.