<![CDATA[ formit2db with autocreate schema&classes - My 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:

[[!FormIt? 
&hooks=`spam,formit2db,email` 
&preHooks=`db2formit`
&prefix=`user_`
&packagename=`test`
&tablename=`test`
&classname=`test`
&where=`{"user_id":"12"}`
&fieldname=`user_id`
]]

]]>
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

[[!FormIt? 
&hooks=`spam,formit2db,email` 
&preHooks=`db2formit`
&prefix=`user_`
&packagename=`test`
&tablename=`test`
&classname=`test`
&where='{"user_id":12}'
]]


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!

[[!FormIt? 
&hooks=`spam,formit2db,email` 
&preHooks=`db2formit`
&prefix=`user_`
&packagename=`test`
&tablename=`test`
&classname=`test`
&where='{"user_id":12}'
]]
 
<h2>Resource Form</h2>
[[+fi.id]]
<p>[[+fi.error.error_message]]</p>
<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">
        user_id:
        <span class="error">[[+fi.error.user_id]]</span>
    </label>
    <input id="user_id" name="user_id" type="number" value="[[+fi.user_id]]">    
     
 
    <label for="address">
        address:
        <span class="error">[[+fi.error.address]]</span>
    </label>
    <input id="address" name="address" type="text" value="[[+fi.address]]">
<br class="clear">
<div class="form-buttons">
        <input type="submit" value="Save">
    </div>
</form>
]]>
[email protected] 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
https://github.com/Jako/FormIt2db/blob/master/core/components/formit2db/elements/snippets/formit2db.snippet.php#L15

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
&prefix=``

and
   tablePrefix=""

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
&preHooks=`profile,db2Formit`
]]>
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:

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
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 '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;


This is my formit call:

[[!FormIt?
   &hooks=`Formit2db,email`
   &preHooks=`[[!profile]],db2Formit`
   &prefix=`modx_custom_`
   &packageName=`transport4u`
   &tablename=`modx_custom_transport4u`
   &emailFrom=`[email protected]`
   &emailTpl=`myEmailChunk`
   &emailTo=`[[+demail]]`
   &emailCC=`[email protected]`
   &emailSubject=`Your Delivery Request Quote`
   &validate=`dname:required,
      demail:required,
      workmail:blank,
      province:required,
      datepicker:required,
      country:required,
      package:required,
      method:required,
      name4:required,
      name2:required,
      name1:required,
      name3:required,
      comment:required:stripTags`


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" />
	</object>
</model>


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