<![CDATA[ formit2db with autocreate schema&classes - MODX Community Forums]]> https://forums.modx.com/thread/?thread=32560 <![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=10#dis-post-545643 BearsFan try this:


mrhaw Oct 12, 2016, 08:26 PM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=10#dis-post-545643
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=10#dis-post-538543
I'm not sure how to setup the FormIt call parameters &paramname and &fieldname and how to use them, and how the &where factors in....can anyone quickly post an example?

Quote from: stowelly at Sep 18, 2013, 06:52 PM
if you want to edit table-row add &resId=yourRowID to your URL <- replace yourRowID with id of tablerow

im having trouble with working out how this is supposed to work? is row id the primary key in my table? for one table I have a dual key, how would that work?

also I cant see any reference to "resId" in the code from package manager, so im guessing from the docs im supposed to use the "where" clause? I cant seem to get this correct either, here is my formit call


but it doesnt do what i am hoping...... I was hoping that if a value was specified then it would grab that row from my db and fill the fields (provided i use the fi.fieldname type bits).... will paste my whole resource in, incase anyone can see what it is im doing wrong, but im really stumped with this!

<h2>Resource Form</h2>
<form class="form" action="[[~[[*id]]]]" method="post">
<input name="resource_id" type="hidden" value="[[+fi.id]]">
    <input name="nospam" type="hidden">
    <label for="user_id">
        <span class="error">[[+fi.error.user_id]]</span>
    <input id="user_id" name="user_id" type="number" value="[[+fi.user_id]]">    
    <label for="address">
        <span class="error">[[+fi.error.address]]</span>
    <input id="address" name="address" type="text" value="[[+fi.address]]">
<br class="clear">
<div class="form-buttons">
        <input type="submit" value="Save">
acaffiero@gmail.com Feb 19, 2016, 01:31 PM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=10#dis-post-538543
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538146
I tried to change the snippets:

1. $prefix = $modx->getOption('prefix', $scriptProperties, ""), true);
2. $prefix = $modx->getOption('prefix', $scriptProperties, null), true);
3. $prefix=""
4. $prefix=null;

but result is same.
With these values XML schema doesn't include the table it supposed to add.

Maybe MODX absolutelly need the $prefix variable to work with XPDO (?).
johnxx Feb 11, 2016, 05:02 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538146
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538142

This can't be changed in the package without BC. So duplicate both hooks and change the duplicated code to your needs.]]>
Jako Feb 11, 2016, 03:44 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538142
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538125
I'd like to use formit2db & db2formit with non-prefixed table.
The snippet works fine with default prefixed tables ("modx_xxxxx") and with custom prefix (
"custom_xxxx", &prefix="custom_"

But when I try to work with tables without prefix (xxxxxx), there is no output.
Even with param


in xml schema (cf. https://rtfm.modx.com/xpdo/2.x/getting-started/creating-a-model-with-xpdo/defining-a-schema/defining-the-database-and-tables)

Is there a way to force the snippet to work with table without prefix?]]>
johnxx Feb 10, 2016, 10:53 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-538125
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529628
Jako Aug 07, 2015, 06:37 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529628
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529627 What I did was remove the prefix from the tablename and the now I can see the data in the database smiley

I am still getting this in Modx error log though:

[2015-08-07 19:08:32] (ERROR @ /index.php) [FormIt] Could not find hook "".
[2015-08-07 19:09:22] (ERROR @ /index.php) [FormIt] Could not find hook "".

I am using a 'profile' prehook to auto fill some fields in the formit form and this is causing this issue (if I remove it then there is no errors).
I can see that the fields are loading ok when I use it so I got to look at the profile fields (later because this is small issue).
jimmyjazz Aug 07, 2015, 06:27 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529627
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529556
After submit, no data is going to the table and I'm getting the following errors in Modx error log:

[2015-08-06 19:07:54] (ERROR @ /index.php) [FormIt] Could not find hook "".
[2015-08-06 19:07:54] (ERROR @ /index.php) Could not load class: ModxCustomTransport4u from mysql.modxcustomtransport4u.
[2015-08-06 19:07:54] (ERROR @ /index.php) ModxCustomTransport4u::load() is not a valid static method.
[2015-08-06 19:07:54] (ERROR @ /index.php) Could not load class: ModxCustomTransport4u from mysql.modxcustomtransport4u.

This is the data I created the mysql table with:

CREATE TABLE IF NOT EXISTS `modx_custom_transport4u` (
`id` int(25) unsigned NOT NULL auto_increment,
`dname` varchar(225) NOT NULL default '',
`demail` varchar(20) NOT NULL default '',
`province` varchar(200) NOT NULL default '',
`country` varchar(200) NOT NULL default '',
`package` varchar(200) NOT NULL default '',
`method` varchar(200) NOT NULL default '',
`name4` varchar(200) NOT NULL default '',
`name2` varchar(200) NOT NULL default '',
`name1` varchar(200) NOT NULL default '',
`name3` varchar(200) NOT NULL default '',
`comment` LONGTEXT NOT NULL default '',

This is my formit call:

   &emailSubject=`Your Delivery Request Quote`

This is the schema that is created in folders inside /core/components/ upon submit:

<?xml version="1.0" encoding="UTF-8"?>
<model package="transport4u" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
	<object class="Transport4u" table="transport4u" extends="xPDOSimpleObject">
		<field key="dname" dbtype="varchar" precision="225" phptype="string" null="false" default="" />
		<field key="demail" dbtype="varchar" precision="20" phptype="string" null="false" default="" />
		<field key="province" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="country" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="package" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="method" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="name4" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="name2" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="name1" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="name3" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
		<field key="comment" dbtype="longtext" phptype="string" null="false" />

There is a difference between the class name generated in the schema to the 'class' in the Modx error log.

What do I have to change or adjust to make this work so the data saves to the mysql database?

jimmyjazz Aug 06, 2015, 06:49 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-529556
<![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-526107 Bruno17 May 28, 2015, 07:19 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-526107 <![CDATA[Re: formit2db with autocreate schema&classes]]> https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-526104 Jako May 28, 2015, 06:58 AM https://forums.modx.com/thread/32560/formit2db-with-autocreate-schema-classes?page=9#dis-post-526104