Sorry if this going over covered ground, but I’m seeing the "Call to undefined function ’eForm2db’()..." error in my implementation too. I really want this to work!
Here’s my eForm2db snippet (eForm2dbBanff)
<?php
function eForm2db( &$fields )
{
/*---------------------------------------------------------------
eForm2db
Version: 0.1 [Beta 1]
Author: pixelchutes
---------------------------------------------------------------
Requirements:
eForm 1.4+
---------------------------------------------------------------
Use:
- Takes validated eForm submittal data for use with the MODx DBAPI extender class.
- Easily process database records referencing your form submission data:
+ INSERT new records to a table of your choice
+ UPDATE existing records if you'd prefer
+ DELETE records based on form submittal criteria
+ Form a query and return its record set as XML using $modx->db->getXML
+ Query a table's MetaData using $modx->db->getTableMetaData, followed by an update query
on only the form fields that are named after table columns!
+ and much more!
---------------------------------------------------------------*/
// Bring needed resources into scope
global $modx, $table_prefix;
// Init our array
$dbTable = array(); // key = DB Column; Value = Insert/Update value
$dbTable['firstname'] = $fields['firstname'];
$dbTable['lastname'] = $fields['lastname'];
$dbTable['email'] = $fields['email'];
$dbTable['phone'] = $fields['phone1'].$fields['phone2'].$fields['phone3'];
$dbTable['address'] = $fields['address'];
$dbTable['city'] = $fields['city'];
$dbTable['state'] = $fields['state'];
$dbTable['postal'] = $fields['postal'];
$dbTable['gender1'] = $fields['gender1'];
$dbTable['size1'] = $fields['size1'];
$dbTable['gender2'] = $fields['gender2'];
$dbTable['size2'] = $fields['size2'];
$dbTable['garments'] = $fields['garments'];
$dbTable['activities'] = $fields['activities'];
$dbTable['thoughts'] = $fields['thoughts'];
$dbTable['optin'] = $fields['optin'];
// Insert field/value pairs to insert/update in our table
// INSERT - $dbQuery = $modx->db->insert( $dbTable, $table_prefix . 'insertTableName' );
// UPDATE - $dbQuery = $modx->db->update( $dbTable, $table_prefix . 'updateTableName' );
// DELETE - $dbQuery = $modx->db->delete( $table_prefix . 'deleteFromTableName', 'some_field = 1 AND name=\''.$dbTable[name].'\'', '' );
// etc...
// Run the db insert query
$dbQuery = $modx->db->insert( $dbTable, 'pl_banff_contest' );
return true;
}
return '';
?>
And here’s the eForm call on a cacheable page
[!eForm? &runSnippet=`eForm2dbBanff` &formid=`banffContestForm` &noemail=`true` &eFormOnBeforeMailSent='eForm2db' &tpl=`banff-contest-form` &thankyou=`thank-you-contest` &vericode=`1`!]
and if it’s useful, the test page:
http://staging.altny.com/featured-content/banff-film-festival-contest-entry.html
ModX 1.0.4/eForm 1.4.4.6
I’ve just been wrestling with this for a while, and I definitely need some outside advice. I’m hoping it’s something blindingly obvious that I’m overlooking. Thanks in advance!