Hello all!
We have Chrono Contact 3.1 RC5.2 (= ChronoForms?) running on Joomla 1.5.17. You can have a look at the form in question here: http://schwabacher-citylauf.de/anmeldung.html (German)
To make sure that some essential data is entered correctly, I put a server side validation in place. That works very nicely, the only issue I have is with the output it produces:[attachment=0]Resultat.jpg[/attachment]
The unsorted list is just what I am looking for and what is coded in the validation PHP script. However, there is this line starting with "1." which I can't explain. Is this hardcoded in the validation? If so, how can I make use of it and put my error messages in this sorted list? These questions keep me from being fully happy with my form and ChronoForms. Great work, btw!
Here's the code used:
Thanks a lot for your comments!
Regards
Roland
We have Chrono Contact 3.1 RC5.2 (= ChronoForms?) running on Joomla 1.5.17. You can have a look at the form in question here: http://schwabacher-citylauf.de/anmeldung.html (German)
To make sure that some essential data is entered correctly, I put a server side validation in place. That works very nicely, the only issue I have is with the output it produces:[attachment=0]Resultat.jpg[/attachment]
The unsorted list is just what I am looking for and what is coded in the validation PHP script. However, there is this line starting with "1." which I can't explain. Is this hardcoded in the validation? If so, how can I make use of it and put my error messages in this sorted list? These questions keep me from being fully happy with my form and ChronoForms. Great work, btw!
Here's the code used:
<?php
$error="<ul>";
if($_POST['Abbuchen']=="Ja"){
if($_POST['Kontoinhaber'] == ""){
$error.="<li>Bei Abbuchung bitte vollständige Bankverbindung angeben!</li>";
$errors=1;
}
if(!ereg( "^([0-9]{1,10})$",$_POST['Kontonummer'])){
$error.="<li>Die Kontonummer ist ungültig. (Keine Leer- oder Sonderzeichen verwenden!)</li>";
$errors=1;
}
if(!ereg( "^([0-9]{8})$",$_POST['Bankleitzahl'])){
$error.="<li>Die Bankleitzahl ist ungültig. (Keine Leerzeichen verwenden!)</li>";
$errors=1;
}
}
if(!ereg( "^([0-9]{4})$",$_POST['Jahrgang'])){
$error.="<li>Bitte den Jahrgang vierstellig angeben!</li>";
$errors=1;
}
if($_POST['Lauf'] == "1" && $_POST['Jahrgang'] < "2003"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$errors=1;
}
elseif($_POST['Lauf'] == "2" && $_POST['Jahrgang'] < "1997"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$errors=1;
}
elseif($_POST['Lauf'] == "3" && $_POST['Jahrgang'] > "1996"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$errors=1;
}
elseif($_POST['Lauf'] == "4" && $_POST['Jahrgang'] > "1994"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$errors=1;
}
elseif($_POST['Lauf'] == "5" && $_POST['Jahrgang'] > "1994"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$errors=1;
}
$error.="</ul>";
if($errors==1) return $error;
?>Thanks a lot for your comments!
Regards
Roland
Hi Roland,
I don't think you can get rid of that numbered list (1.) without a core hack.
Regards,
Max
I don't think you can get rid of that numbered list (1.) without a core hack.
Regards,
Max
Hi Max,
thanks for your kind reply!
Does anybody perhaps know of a way which would allow me to utilise that numbered list? That is, to get more then just one error message displayed without using the way used in my current code?
Yours,
Roland
thanks for your kind reply!
Does anybody perhaps know of a way which would allow me to utilise that numbered list? That is, to get more then just one error message displayed without using the way used in my current code?
Yours,
Roland
This is very strange indeed.
The core just says (chronocontact.html.php, line 162):
The <ol> tag turns it into an ordered list. The strange thing is, that even when you remove the <ol> altogether from the core, it still returns an <li> tag! Where does this tag come from?
The core just says (chronocontact.html.php, line 162):
<?php if($MyForm->formerrors){ ?>
<span class="cf_alert"><?php echo '<ol>'.$MyForm->formerrors.'</ol>'; ?></span>
<?php } ?>The <ol> tag turns it into an ordered list. The strange thing is, that even when you remove the <ol> altogether from the core, it still returns an <li> tag! Where does this tag come from?
The <ol> tag turns it into an ordered list. The strange thing is, that even when you remove the <ol> altogether from the core, it still returns an <li> tag! Where does this tag come from?
I think I found it in the library chronoform.php, lines 141-143:
function addErrorMsg( $text )
{
$this->formerrors = $this->formerrors.'<li>'.$text.'</li>';var $formerrors = ''; is defined in line 16 of that file.And there is this, starting at line 252:
function checkServerValidation($formname)
{
global $mainframe;
$session =& JFactory::getSession();
$MyForm =& CFChronoForm::getInstance($formname);
if ( trim($MyForm->formparams('servervalidate')) == 'Yes' ) {
if ($returnval = eval( "?>".$MyForm->formrow->server_validation )){
$MyForm->resetSubmissionsLimit($formname);
$MyForm->addErrorMsg($returnval);
}
}
}What do you make of this?
Cheers,
Roland
Hello again,
with the help of a friend of mine who understands quite a lot more of the matter than myself we found a quite elgant workaround solution:
What ever the output of the code used for server side validation is, it is enveloped in <li></li> tags by chronoforms function AddErrorMessage. By using this line:
we remove those tags from our own list, make use of the list already provided and kind of sneak our own list in that. Goal accomplished, user (me) happy.
[attachment=0]error.jpg[/attachment]
Thanks a lot for your kind help and time!
Yours,
Roland
with the help of a friend of mine who understands quite a lot more of the matter than myself we found a quite elgant workaround solution:
<?php
if($_POST['Abbuchen']=="Ja"){
if($_POST['Kontoinhaber'] == ""){
$error.="<li>Bei Abbuchung bitte vollständige Bankverbindung angeben!</li>";
$Problem=1;
}
if(!ereg( "^([0-9]{1,10})$",$_POST['Kontonummer'])){
$error.="<li>Die Kontonummer ist ungültig. (Keine Leer- oder Sonderzeichen verwenden!)</li>";
$Problem=1;
}
if(!ereg( "^([0-9]{8})$",$_POST['Bankleitzahl'])){
$error.="<li>Die Bankleitzahl ist ungültig. (Keine Leerzeichen verwenden!)</li>";
$Problem=1;
}
}
if(!ereg( "^([0-9]{4})$",$_POST['Jahrgang'])){
$error.="<li>Bitte den Jahrgang vierstellig angeben!</li>";
$Problem=1;
}
if($_POST['Lauf'] == "1" && $_POST['Jahrgang'] < "2003"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$Problem=1;
}
elseif($_POST['Lauf'] == "2" && $_POST['Jahrgang'] < "1997"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$Problem=1;
}
elseif($_POST['Lauf'] == "3" && $_POST['Jahrgang'] > "1996"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$Problem=1;
}
elseif($_POST['Lauf'] == "4" && $_POST['Jahrgang'] > "1994"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$Problem=1;
}
elseif($_POST['Lauf'] == "5" && $_POST['Jahrgang'] > "1994"){
$error.="<li>Der Jahrgang ist für den gewünschten Lauf nicht zugelassen.</li>";
$Problem=1;
}
$error=substr($error,4,-5);
if($Problem==1) return $error;
?>What ever the output of the code used for server side validation is, it is enveloped in <li></li> tags by chronoforms function AddErrorMessage. By using this line:
$error=substr($error,4,-5);we remove those tags from our own list, make use of the list already provided and kind of sneak our own list in that. Goal accomplished, user (me) happy.
[attachment=0]error.jpg[/attachment]
Thanks a lot for your kind help and time!
Yours,
Roland
This topic is locked and no more replies can be posted.
