We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30585
    • 833 Posts
    Hi all,

    I just finished creating a snippet and chunk to populate eform with dynamic data as per the tutorial available in the Wiki. http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data#Create_the_Database_Table

    I also created the required modx_mymail_messages table in the database and all the fields necessary with the suggested propersties in the tutorial.

    The form is operating properly as far as validating and submiting data.

    The problem is that there are still no records in the database table.

    Here’s my table structure

    id - unsigned int(5)
    name - varchar(100)
    email - varchar(100)
    subject - varchar(100)
    message - text


    Here my snippet calls

    [!MyMailParser!]
    [!eForm? &tpl=`eFormMailMe` &formid=`EmailForm` &eFormOnBeforeFormParse=`populateMailForm`!]


    And here’s the link to the test page http://itconsmedia.net/mail.html

    I will appreciate any help.

    Thanks
      A MODx Fanatic
      • 3749
      • 24,544 Posts
      There’s eForm3DB http://modxcms.com/forums/index.php/topic,8111.0.html

      This snippet has been around for quite a while, but for some reason hasn’t made it to the MODx Repository.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 30585
        • 833 Posts
        Hi BobRay,

        Thanks for the tip. I’m working on it now and I hope it will work because I was quiete stuck with the solution I tried first
          A MODx Fanatic
          • 30585
          • 833 Posts
          Quote from: treigh at Sep 21, 2008, 04:21 AM

          Hi BobRay,

          Thanks for the tip. I’m working on it now and I hope it will work because I was quiete stuck with the solution I tried first


          I tried this, but all i’m getting is a white page on page load. See here http://itconsmedia.net/index.php?id=47
          It seems very straightforward, but somehow it’s still not working.

          Any help please
            A MODx Fanatic
            • 3749
            • 24,544 Posts
            I’ve never used eForm2DB so I may not be much help.

            Did you create the snippet? Are you sure the spelling in your snippet call matches the name of the snippet (it’s case-sensitive).

            Paste your snippet call from the blank page into a reply here so we can look at it.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              And your custom snippet has to be called before the eForm snippet call.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 30585
                • 833 Posts
                Hi guys,

                I should point out that when I remove the [[eForm2db]] call, the form shows up just fine. I can give you access to the manager so you can view it first-hand if you want

                Here are my snippet calls.


                [[eForm2db]]
                [!eForm? &noemail=`true` &formid=`ecrewquoteform` &eFormOnBeforeMailSent=`eForm2db` &tpl=`ecrew-quoteform2` &automessage=`ecrew-quotethankyou`!]

                Thanks for your help.


                  A MODx Fanatic
                  • 7231
                  • 4,205 Posts
                  You must have a syntax error in your eform2db code. Double check it for missing ; ) } and ". Also check for typos in the function name.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 30585
                    • 833 Posts
                    Hi there,

                    Thanks for taking the time to help. I really appreciate it. I did a quick check, I must admit that I’m not a PHP guru, but I don’t see any problem.
                    Here’s the code

                    <?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
                    
                    		// Insert field/value pairs to insert/update in our table
                    		$dbTable[name] = $fields[first_name].' '.$fields[last_name]; // Merge two form fields together
                    		$dbTable[datetime] = date( 'YmdHis', strtotime( $fields[postdate] ) ); // Massage the postdate timestamp to be MySQL insert friendly
                    
                    
                    		// 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, $table_prefix . 'insertTableName' );		
                    
                    		return true;
                    	}
                    	// Return empty string
                    	return '';
                    ?>
                      A MODx Fanatic
                      • 3749
                      • 24,544 Posts
                      It looks as though this code is just a suggestion of how to do things. It would need to be customized for your needs. It assumes, for example, that you have a first_name and last_name field in your table and a datetime field. I also don’t see any place that’s selecting the DB table you want to modify. I guess that’s why it’s Version 0.1 Beta 1 wink
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting