[[OnBeforeMailSent]] [!eForm? &formid=`NLForm` &to=`[email protected]` &from=`[email protected]` &subject=`Newsletter Sign-up` &tpl=`Newsletter_Chunk` &report=`customreport` &eFormOnValidate=`mytestfunction`!]
// OnBeforeMailSent snippet;
function mytestfunction()
{
// I want to add an error message to the Eform [+validationmessage+] at this point
// I want to tell Eform to cease processing if the following return is `false`
$mymessage = "This would be my validation message";
return false;
} // end function
&eFormOnValidate (optional)
Expects a function name. This function will be called directly after the form validation has taken place. You can use this event to add your own extra validation logic. The function should accomodate the following parameters
&$fields - (as reference) an associative array of field and placeholder values.
&$vMsg - (as reference) a numeric array of validation error messages.
&$rMsg - (as Reference) a numeric array of missing required fields.
function mytestfunction(&$fields, &$vMsg, &$rMsg) {
global $modx;
/*
&$fields - (as reference) an associative array of field and placeholder values.
&$vMsg - (as reference) a numeric array of validation error messages.
&$rMsg - (as Reference) a numeric array of missing required fields.
*/
$vMsg[3] = "Error Message";
return $vMsg;
} // end function
1. Eform call creates a unique activation key upon &eFormOnValidate
2. Put activation key into a placeholder?
3. Email digest report should allow usage of placeholder

<form method="get" action="[~[*id*]~]"> </form>
How do you make eFormOnValidate work with a GET command?
<form method="get" action="[~[*id*]~]"> </form>
I have a form which will act as a search, but if I try to use GET eFormOnValidate never runs, however I can use GET variables inside eFormOnBeforeFormParse.
[!eventFunctionSnippet!] [!eForm? &eFormOnBeforeFormParse=`formParseEvent` &eFormOnBeforeMailSent=`formParseResults` &formid=`HSF` &tpl=`simple_form` &noemail=`0` &debug=`1`!]
<?php
//search-results
function formParseResults( &$fields, &$templates )
{
// I want this to actually do the query that appears in formParseEvent
}
function formParseEvent( &$fields, &$templates, $debug=false )
{
global $modx, $vMsg;
$debug = false;
if ($debug == true)
{
print '<pre>GET: '. print_r($_GET) . '</pre>';
print '<pre>POST:'. print_r($_POST) . '</pre>';
print '<pre>FIELDS: '. print_r($fields) . '</pre>';
print '<pre>vMsg: '. print_r($vMsg) . '</pre>';
print '<pre>rMsg: '. print_r($rMsg) . '</pre>';
print '<p>' . $modx->getPlaceholder('validationmessage') . '</p>';
}
global $modx, $vMsg;
$output = '';
$basePath = $modx->config['base_path'];
$siteURL = $modx->config['site_url'];
include_once( $basePath .'assets/snippets/curl/holiday.php' );
$Holiday = new Holiday(&$modx);
$sarray = $Holiday->processForm();
$outcome = $Holiday->build_sql($sarray);
// I cannot seem to use this placeholder anywhere, but in this function
// even if I return the placeholder
$modx->setPlaceholder('holidaySearchResults', $outcome);
return (true);
} // end function
?>
Here’s what I’ve done;Firstly it seems to me that the eFormOnValidate would be a better event to use because it only triggers when the form is submitted and secondly at least you’ll know that according to eForm everything validates. The fact that you validate the form results in your custom library does not turn off eForms validation.
1) Built the form
2) Created a custom library to handle all the validation outside of Eform
3) Added `eFormOnBeforeFormParse` and `eFormOnBeforeMailSent` to the eform.
4) Created a snippet with the relevant functions;
[!eventFunctionSnippet!] [!eForm? &eFormOnBeforeFormParse=`formParseEvent` &eFormOnBeforeMailSent=`formParseResults` &formid=`HSF` &tpl=`simple_form` &noemail=`0` &debug=`1`!]
How do I get Eform to display the results as generated by the placeholder "holidaySearchResults"?Using modx->setPlaceholder stores the results for further processing by the modx document parser. This happens after eForm has finished and so the value will not be available to eForm ( unless you retrieve it yourself in code with $modx->getPlaceholder() ). You could simply add it to the $fields array ($fields[’holidaySearchResults’] = $outcome;) and later on retrieve it from there. At least I’m assuming that your aim here is to propagate the $outcome value to the next event function?