$o_form->setJqueryValidation(true); //You can specify that the javascript is sent into a placeholder for those that have jquery scripts just before body close. If jquery scripts are in the head, no need for this. $o_form->setPlaceholderJavascript('JsonFormBuilder_myForm'); //After creating all your form elements add them $o_form->addElements(array($o_fe_name, $o_fe_email, $o_fe_notes, $o_fe_buttSubmit)); //Load our custom package. This could be done well befoer even running your form snippet. //As long as the package is loaded prior to using your custom database you will be fine. $packageName = 'testpackage'; $path = MODX_CORE_PATH . 'components/' . $packageName . '/'; $packageLoadResult = $modx->addPackage($packageName, $path . 'model/', $packageName . '_'); if ($packageLoadResult === false) { //log or throw an error in some way. echo 'Failed to load package "' . $packageName . '"'; exit; } //must force form to run validate check prior to checking if submitted $o_form->validate(); if ($o_form->isSubmitted() === true && count($o_form->getInvalidElements()) === 0) { //form was submitted and is valid. Now we can record the data to the databse table //Of course you may want to secure some of the post variables before they enter your database as well. $o = $modx->newObject('Contactlog'); $o->set('name_full', $o_form->postVal('name_full')); $o->set('email_address', $o_form->postVal('email_address')); $o->set('comments', $o_form->postVal('comments')); $o->set('email_html_content', $o_form->getEmailContent()); $o->set('time_submitted', time()); $o->save(); } //The form HTML will now be available via teh output call //This can be returned in a snippet or passed to any other script to handle in any way. //$o_form->output();