I'm using the "Server Side Validation Code" area to report data entry errors. That works great.
If the validation succeeds I want to show a "green happy box" at the top of the same form. I already have php code that locks all the fields and shows a message, but don't see how I can get the chronoengine to show it. Instead, I get an empty body tag when validation succeeds.
Is there a natural way to hook into chronoforms so I can display the same form again when validation succeds? The ServerSide Validation feature only seems to handle an error, everything else goes to a blank body tag.
If the validation succeeds I want to show a "green happy box" at the top of the same form. I already have php code that locks all the fields and shows a message, but don't see how I can get the chronoengine to show it. Instead, I get an empty body tag when validation succeeds.
Is there a natural way to hook into chronoforms so I can display the same form again when validation succeds? The ServerSide Validation feature only seems to handle an error, everything else goes to a blank body tag.
Hi joomlanoob,
Any PHP+HTML that you put in the OnSubmit boxes will display on the 'blank' page if you submit successfully. if you want to show the form again you can put the form url into the RedirectURL.
Bob
Any PHP+HTML that you put in the OnSubmit boxes will display on the 'blank' page if you submit successfully. if you want to show the form again you can put the form url into the RedirectURL.
Bob
Thanks for the reply.
I tried it but the Redirect URL seems to do what the name implies --- redirect. None of the form's posted data appears in the form. Also it overrides all the "On Submit" code blocks because the PHP code I placed into the "On Submit code - before sending email" and the "On Submit code - after sending email" does not execute when a Redirect URL is supplied.
Could there be a variable I could set in PHP code in a "On Submit code block" that would cause the chronoengine to think there was an error but not to display an error message? That would get me exactly what I need (because I'll display a happy message myself at that point.)
I'll keep tinkering and share what I find if I stumble into a solution.
I tried it but the Redirect URL seems to do what the name implies --- redirect. None of the form's posted data appears in the form. Also it overrides all the "On Submit" code blocks because the PHP code I placed into the "On Submit code - before sending email" and the "On Submit code - after sending email" does not execute when a Redirect URL is supplied.
Could there be a variable I could set in PHP code in a "On Submit code block" that would cause the chronoengine to think there was an error but not to display an error message? That would get me exactly what I need (because I'll display a happy message myself at that point.)
I'll keep tinkering and share what I find if I stumble into a solution.
Okay, found a way to do it. I enchanged the validation processor to treat a message starting with "GOOD:" as a success message. Such messages appear in green, everthing else behaves as though there were a validation error.
The only edited file was "chronocontact.html.php". Here is the edited section...
==============
<?php
//Frank Font Validation Enhancement 2009-04-04
//Support both ERROR and HAPPY message in the VALIDATION block.
//If message starts with 'GOOD:' then validation shows an happy message instead.
//The 'GOOD:' is stripped off before showing the message.
if($session->get('chrono_verification_msg', '', md5('chrono')))
{
$ver_error_message = $session->get('chrono_verification_msg', 'default', md5('chrono'));
if(substr(trim($ver_error_message),0,5) == 'GOOD:')
{
//This is not really an error, it is something happy!
$happy_message = substr(trim($ver_error_message),5);
?>
<style type="text/css">
span.cf_alert {
background:#ccffcc url(<?php echo JURI::Base().'components/com_chronocontact/css/'; ?>images/ff_icon_good_24x24.png) no-repeat scroll 5px 50%;
border:1px solid #009933;
color:#009933;
display:block;
margin:15px 0pt;
padding:8px 10px 8px 36px;
}
</style>
<span class="cf_alert"><?php echo $happy_message ?></span>
<?php } else {
//Not a happy message.
?>
<style type="text/css">
span.cf_alert {
background:#FFD5D5 url(<?php echo JURI::Base().'components/com_chronocontact/css/'; ?>images/ff_icon_error_24x24.png) no-repeat scroll 5px 50%;
border:1px solid #FFACAD;
color:#CF3738;
display:block;
margin:15px 0pt;
padding:8px 10px 8px 36px;
}
</style>
<span class="cf_alert"><?php echo $ver_error_message ?></span>
<?php } //End type of message
} //End check for a message ?>
==============
I tested it with the following simple entry in the "Server Side validation Code: " block...
==============
<?php
//Simple test of the modified chronoform validation logic
if($_REQUEST['firstname'] == 'a')
{
return "GOOD:Say something happy";
} else {
return "Say something unhappy";
}
?>
==============
Note, the PNG files in the code are not on the regular distribution. Let me know if you want them and I can post them too. They are just a green checkmark (good) and a red X (error) in 24x24 px size.
The only edited file was "chronocontact.html.php". Here is the edited section...
==============
<?php
//Frank Font Validation Enhancement 2009-04-04
//Support both ERROR and HAPPY message in the VALIDATION block.
//If message starts with 'GOOD:' then validation shows an happy message instead.
//The 'GOOD:' is stripped off before showing the message.
if($session->get('chrono_verification_msg', '', md5('chrono')))
{
$ver_error_message = $session->get('chrono_verification_msg', 'default', md5('chrono'));
if(substr(trim($ver_error_message),0,5) == 'GOOD:')
{
//This is not really an error, it is something happy!
$happy_message = substr(trim($ver_error_message),5);
?>
<style type="text/css">
span.cf_alert {
background:#ccffcc url(<?php echo JURI::Base().'components/com_chronocontact/css/'; ?>images/ff_icon_good_24x24.png) no-repeat scroll 5px 50%;
border:1px solid #009933;
color:#009933;
display:block;
margin:15px 0pt;
padding:8px 10px 8px 36px;
}
</style>
<span class="cf_alert"><?php echo $happy_message ?></span>
<?php } else {
//Not a happy message.
?>
<style type="text/css">
span.cf_alert {
background:#FFD5D5 url(<?php echo JURI::Base().'components/com_chronocontact/css/'; ?>images/ff_icon_error_24x24.png) no-repeat scroll 5px 50%;
border:1px solid #FFACAD;
color:#CF3738;
display:block;
margin:15px 0pt;
padding:8px 10px 8px 36px;
}
</style>
<span class="cf_alert"><?php echo $ver_error_message ?></span>
<?php } //End type of message
} //End check for a message ?>
==============
I tested it with the following simple entry in the "Server Side validation Code: " block...
==============
<?php
//Simple test of the modified chronoform validation logic
if($_REQUEST['firstname'] == 'a')
{
return "GOOD:Say something happy";
} else {
return "Say something unhappy";
}
?>
==============
Note, the PNG files in the code are not on the regular distribution. Let me know if you want them and I can post them too. They are just a green checkmark (good) and a red X (error) in 24x24 px size.
Hi Joomlanoob,
Neat hack.
You didn't say that you wanted to re-show the data on the form. You can use
Bob
Neat hack.
You didn't say that you wanted to re-show the data on the form. You can use
<?php
showform($post);
$error_found = true;
?>
to do that, and <?php
global $mainframe;
$mainframe->enqueuemessage('some text');
?>
will display a message provided that your template supports Joomla System messages.Bob
If I understand this...
<?php
showform($post);
$error_found = true;
?>
... it seems better than my hack since I dont have to modify the provided chronoform file. Thanks.
I'll give it a try later today.
<?php
showform($post);
$error_found = true;
?>
... it seems better than my hack since I dont have to modify the provided chronoform file. Thanks.
I'll give it a try later today.
Hi joomlanoob,
I think that Max may have improved this again in RC4 but I haven't had a proper chance to look yet.
Bob
I think that Max may have improved this again in RC4 but I haven't had a proper chance to look yet.
Bob
Thanks for the great advice GreyHead!
All my custom field validation code is now in the "Form HTML" block. The "On Submit code" block is hardcoded with "showform($post) and $error_found=true;". My custom code displays an error message or happy message, in either case I want all the fields displayed and this does it.
I'm no longer using the chronoforms ServiceSide Validation block at all.
And with this approach there is no longer a need to edit the default chronoforms php file.
All my custom field validation code is now in the "Form HTML" block. The "On Submit code" block is hardcoded with "showform($post) and $error_found=true;". My custom code displays an error message or happy message, in either case I want all the fields displayed and this does it.
I'm no longer using the chronoforms ServiceSide Validation block at all.
And with this approach there is no longer a need to edit the default chronoforms php file.
This topic is locked and no more replies can be posted.