Republish fields after Server Side validation does not work

vogglz 29 Jun, 2009
Hi there,

hope some of you gurus will help me out: I'm trying to create a form using CF for the first time and really like it, but I'm having some issues with republishing the fields after using some home-made SS validation.

Versions
Joomla! 1.5.11 Stable
CF 3.1 RC5.1

Form description
Dynamic quotation request form using useableforms.js.

Goal
Validating form using server side validation. If it fails, I need it to republish.

Settings
CF General => Republish fields if error occured = Try to Republish
CF Validation => JS => Enable validation = No (I've also tried this with Yes, same result)
CF Validation => SS => Enable Server Side Validation = Yes

SS Validation Code
<?php 

function check_email_address($email) {
  // Check for one @ symbol and lengths are OK
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
     return false;
    }
  }
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; // Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}

    if($_POST["voornaam"]=="") {
        $message="Vul uw voornaam in a.u.b.<br />";
    }

    if($_POST["achternaam"]=="") {
        $message.="Vul uw achternaam in a.u.b.<br />";
    }

    if($_POST["telefoon"]=="") {
        $message.="Vul uw telefoonnummer in a.u.b.<br />";
    }
    
    if (!ereg("^(\(?\+?[0-9]*\)?)?[0-9_\-\(\)]*$", $_POST["telefoon"])) {
        $message.="Het door u ingevulde telefoonnummer is niet correct. Controleer uw invoer a.u.b.<br />";
    }

    if(!check_email_address($_POST["email"])) {
        $message.="Het door u ingevulde e-mailadres is niet in orde. Controleer uw invoer a.u.b.<br />";
    }

return $message;
?>


Problem
SS validation code is working like it should, errors display as they should, but fields are not being republished. The form is quite complex, but validation only has to occur on first 4 fields (first name, last name, email, phone).

Please help! Any input or suggestion is appreciated, thanks!
Max_admin 30 Jun, 2009
Hi Vogglz,

if Try to republish is on and it doesn't work then there is some problem, my suggestion is to get RC5.2 since the republish code is completely different and is using PHP now instead of JS as in RC5.1 and previous versions, I think the issue with your for is that maybe it has a JS error which prevents the form from reloading

RC5.2 will be available later today!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vogglz 30 Jun, 2009
Hi Max,

that is excellent news, I'll keep you posted if this solved my problem or not.

Thanks,

Vogglz
vogglz 14 Jul, 2009
Hi again Max,

just installed RC5.3, which initially seemed to solve my problem. Unfortunately, it made them bigger...

Although upon error, the form republished information in fields perfectly ok, it seems to check unchecked boxes and vice versa. So you get the exact opposite result when it comes to the checkboxes.

Also, I am using useableforms.js to dynamically control my large form (with the before mentioned checkboxes). As soon as it republishes, the .js is totally burned and does not function at all anymore.

Thanks in advance,

Frank

P.S: Maybe the useableforms compatibility with server-side validation is a bit much to ask, no problem if it is. I am using Chronoforms for the first time, and just want to see how far I can go with it without spending too much time. I will definitely buy a 5 site license as soon as I've finished this pilot project. The work you've done on CF is excellent.
Max_admin 16 Jul, 2009
Hi Vogglz,

republishing has a small glitch in RC5.3, if you want a fixed version then contact me through the contact us page to get RC5.31, only this small glitch is fixed, RC5.4 coming with more enhancements soon

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vogglz 16 Jul, 2009
Hi Max,

thanks, I'll just wait for 5.4. The data being submitted is not extremely important and does not get put into a database, so I've just disabled server-side validation for now. I'm curious to see if 5.4 will solve my problems with the usableforms.js too, what do you reckon?

Any estimate on when RC5.4 will be released?

Thanks,

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