Generating Chronoforms System Messages

johnoathome 12 Jan, 2017
Hi,

Can anyone point me to the function that generates the Chronoforms System Messages?

For example, if you enter an invalid answer to a security question <div class="system-message-container"> is generated with an error "You have entered a wrong security question's answer".

I have a custom PHP script that validates some fields. For consistency I'd like to display errors in the same format as Chronoforms.

Thanks
John
GreyHead 12 Jan, 2017
Hi John,

I believe that is a Joomla! system message. You can add them using code like this
<?php
. . .
$app = \JFactory::getApplication();
$app->enqueueMessage('some message', 'error');
?>
That message will be displayed on the next page load. The 'error' option shows the 'pink' message - there are also other options.

Bob
johnoathome 13 Jan, 2017
Hi Bob,

The code that generates these messages appears to live in /libraries/cegcore/helpers/message.php

The behavior (at least with Ajax form I'm testing) is a bit inconsistent.

On the initial page load, the system-message-container div is contained inside the form. After you submit the first page using Ajax, the div is found in the Joomla system messages location defined by <jdoc:include type="message" /> in the template.

For this application I want all the errors to be included in the form and I'm not particularly interested in Joomla messages, so I've simply removed the include from the template. I'm using the simple javascript function below to forge a Chronforms error. It's a bit ugly and I cant rule out it won't need some tweaking to avoid breaking other Chronoforms validation messages, but it is working well enough at the moment.

Cheers
John

<?php

if(!$validated){
	echo "<script>raise_error('chronoform-reset_password', 'An incorrect reset code was entered');</script>";
}

?>

<script>
function raise_error(calling_form, msg){

	jQuery("#" + calling_form).prepend("<div class='system-message-container'><dl class='system-message'><dd class='validation message'><ul><li>" + msg + "</li></ul></dd></dl></div>");

}

</script>
This topic is locked and no more replies can be posted.