well, i’m not a developer, so understand all the work we need to make for eform2db to work is not easy if it isn’t all in one post ordered step by step, so i decided to help the modx community with this litlle post:
first: we make a table named cargas in the modx database
CREATE TABLE `cargas` (
`id` int(10) unsigned NOT NULL auto_increment,
`fullname` varchar(255) NOT NULL,
`rut` varchar(15) NOT NULL,
`sexo` varchar(5) NOT NULL,
`edad` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT;
second: we need a form to send the info to the database, let’s make the
nuevaCarga chunk
<p class="error">[+validationmessage+]</p>
<form method="post" action="[~[*id*]~]" id="nuevaCarga" name="nuevaCarga">
<fieldset>
<label for="cfName">full name:
<p><input name="fullname" id="cfName" class="text" type="text" eform="Your Name::1:"/></p></label>
<label for="cfEmail">rut:
<p><input name="rut" id="cfEmail" class="text" type="text"/></p> </label>
<label for="cfRegarding">sexo
<p><input name="sexo" id="sexo" class="text" type="text" eform="Form sexo::1" /></p> </label>
<label for="cfMessage">edad:
<p><input name="edad" id="edad" class="text" type="text" eform="Form edad::1" /></p> </label>
<label> </label><p><input type="submit" name="contact" id="cfContact" class="button" value="inscribir" /></p>
</fieldset>
</form>
third: we make the eForm2db like snippet (this snippet is based on
pixelchutes eForm2db, i just adjust to fill the table i used and remove the comments to make the post shorter):
<?php
function agregarCargas( &$fields )
{
global $modx;
// Init our array
$dbTable = array();
$dbTable[fullname] = $fields[fullname];
$dbTable[rut] = $fields[rut];
$dbTable[sexo] = $fields[sexo];
$dbTable[edad] = $fields[edad];
// Run the db insert query
$dbQuery = $modx->db->insert($dbTable, 'cargas' );
return true;
}
?>
fourth:we create a new document with the following snippet calls:
[!agregarCargas!] [!eForm? &noemail=`true` &formid=`nuevaCarga` &eFormOnBeforeMailSent=`agregarCargas` &tpl=`nuevaCarga` &thankyou=`3`!]
i hope this will work to all in the community, it worked for me!
francisco
www.dospuntocero.cl