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

    This was solved by publishing the document. It didn’t work through the preview mode.



    I’ve managed to get eForm2db working as it should, but when I try to implement it with the rest of my templates, it brakes. I’m sure I’ve done something wrong, just can’t figure out what it is.
    Here follows my code:

    My snippet (named dbTavlingSnippet):
    <?php
    function dbTavlingSnippet( &$fields )
    	{
    		global $modx;
    		// Init our array
    		$dbTable = array();
    		$dbTable[meaning] = $fields[meaning];
    		$dbTable[bacillus] = $fields[bacillus];
    		$dbTable[bread] = $fields[bread];
    		$dbTable[price] = $fields[price];
    		$dbTable[year] = $fields[year];
    		$dbTable[motivation] = $fields[motivation];
    		$dbTable[firstname] = $fields[firstname];
    		$dbTable[lastname] = $fields[lastname];
    		$dbTable[phone] = $fields[phone];
    		$dbTable[email] = $fields[email];
    		// Run the db insert query
    		$dbQuery = $modx->db->insert($dbTable, 'tavling' );
    		return true;
    	}
    ?>



    My chunk (named dbTavlingChunk):
    <p class="error">[+validationmessage+]</p>
    <form id="tavling_submit" name="tavling_submit" action="[~[*id*]~]" method="post">
        <fieldset class="odd radio">
            <div class="anfang">
            	1
            </div>
            <div class="clearfix">
            	<h3>Vad betyder Probiotisk?</h3>
                <input type="radio" name="meaning" value="Ditt liv" id="your_life"/>
                <label for="your_life" class="clearfix">
                    Ditt liv
                </label>
                <input type="radio" name="meaning" value="Mitt liv" id="my_life"/>
                <label for="my_life" class="clearfix">
                    Mitt liv
                </label>
                <input type="radio" name="meaning" value="För liv" id="for_liv"/>
                <label for="for_liv" class="clearfix">
                    För liv
                </label>
    		</div>						
        </fieldset>	
    
        <fieldset class="radio">
            <div class="anfang">
            	2
            </div>
            <div class="clearfix">
            	<h3>Vilken sorts mjölksyrebakterie används?</h3>
                <input type="radio" name="bacillus" value="Lactobacillus reuteri protectis" id="reuteri"/>
                <label for="reuteri">
                    Lactobacillus reuteri protectis
                </label>
                <input type="radio" name="bacillus" value="Lactococcus lactis" id="lactis" />
                <label for="lactis">
                    Lactococcus lactis
                </label>
                <input type="radio" name="bacillus" value="Lactococcus lactis" id="lactis2" />
                <label for="lactis2">
                    Lactococcus lactis
                </label>
            </div>
        </fieldset>
    
        <fieldset class="odd radio">
        	<div class="anfang">
            	3
            </div>
            <div class="clearfix">
                <h3>Hur många brödskivor med aktiv bakteriekultur täcker den dagliga dosen av goda probiotiska bakterier?</h3>
                <input type="radio" name="bread" value="1-2" id="one-two" />
                <label for="one-two">
                    1-2
                </label>
                <input type="radio" name="bread" value="3-4" id="three-four"/>
                <label for="three-four">
                    3-4
                </label>
                <input type="radio" name="bread" value="5-6" id="five-six"/>
                <label for="five-six">
                    5-6
                </label>
            </div>
        </fieldset>
        <fieldset class="radio">
        	<div class="anfang">
            	4
            </div>
            <div class="clearfix">
    
                <h3>Hur mycket kostar det att få i sig en effektiv dos av bakteriekultur?</h3>
                <input type="radio" name="price" value="Cirka 10 kronor per dag" id="ten"/>
                <label for="ten">
                    Cirka 10 kronor per dag
                </label>
                <input type="radio" name="price" value="Cirka 5 kronor per dag" id="five" />
                <label for="five">
                    Cirka 5 kronor per dag
                </label>
                <input type="radio" name="price" value="Cirka 1 krona per dag" id="one" />
                <label for="one">
                    Cirka 1 krona per dag
                </label>
            </div>
        </fieldset>
        <fieldset class="odd radio">
        	<div class="anfang">
            	5
            </div>
            <div class="clearfix">
                <h3>Vilket år besteg Renata Chlumska Mount Everest?</h3>
                <input type="radio" name="year" value="1997" id="y1997"/>
                <label for="y1997">
                    1997
                </label>
                <input type="radio" name="year" value="1998" id="y1998"/>
                <label for="y1998">
                    1998
                </label>
                <input type="radio" name="year" value="1999" id="y1999"/>
                <label for="y1999">
                    1999
                </label>
            </div>
        </fieldset>
        <fieldset id="motivation" class="textarea">
        	<div class="anfang">
            	6
            </div>
            <div class="clearfix">
            	<h3>Motivera varför du inte klarar dig utan probiotiska bakterier!</h3>
                <textarea name="motivation" rows="5" cols="50" eform="textarea::1:"></textarea>
                
            </div>						
        </fieldset>
    <fieldset class="odd adress">
        <div>
        	<span class="finstilt">Fält som har ett </span>
            <span class="star">*</span>
            <span class="finstilt">efter sig måste fyllas i för att vi skall kunna kontakta er.</span>
        </div>
        
        <div class="formRow">
            <label for="firstname">Förnamn</label>
            <input class="text" type="text" name="firstname" value="" id="firstname" eform="firstname::1:"/>
            <span class="starFloat">*</span>
        </div>
        
        <div class="formRow">
        	<label for="phone">Telefon</label>
            <input class="text" type="text" name="phone" value="" id="phone" eform="phone::1:"/>
            <span class="starFloat">*</span>
        </div>
        
        <div class="formRow">
            <label for="lastname">Efternamn</label>
            <input class="text" type="text" name="lastname" value="" id="lastname" eform="lastname::1:"/>
            <span class="starFloat">*</span>
        </div>
        
        
        <div class="formRow">
            <label for="email">E-post</label>
            <input class="text" type="text" name="email" value="" id="email" eform="email::1:"/>
            <span class="starFloat">*</span>
        </div>
        
        <div class="approve formRowWide">	
        	<input type="submit" name="send" id="submit" value="Skicka"/>
            <input type="checkbox" name="accept" value="accept" id="accept" eform="accept::1:"/>
            <label for="accept" class="accept">Jag godkänner tävlingsreglerna.</label>
        </div>	
    </fieldset>
    </form> 


    My report chunk (named dbTavlingChunkReport):
    <p>This is a response sent by [+name+] using the feedback form on the website. The details of the message follow below:</p>
    <table>
    <tr valign="top"><td>Name:</td><td>[+firstname+]</td></tr>
    <tr valign="top"><td>Email:</td><td>[+email+]</td></tr>
    <tr valign="top"><td>comments:</td><td>[+phone+]</td></tr>
    </table>
    <p>You can use this link to reply: <a href="mailto:[+email+]?subject=RE:[+subject+]">[+email+]</a></p>
    


    My template (named se-dbTable):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	<title> [*pagetitle*]</title>
    	<link href="lib/css/screen.css" rel="stylesheet" type="text/css" media="screen, projection" />
    	<link href="lib/css/print.css" rel="stylesheet" type="text/css" media="print" />
    	<!--[if lte IE 6]>
    		<script type="text/javascript" src="lib/js/supersleight-min.js"></script>
    	<![endif]-->
    	<script type="text/javascript" src="lib/js/jquery.js"></script>
    	<script type="text/javascript" src="lib/js/jquery.easing.js"></script>
    	<script type="text/javascript" src="lib/js/jquery.accordion.js"></script>
    	<script type="text/javascript" src="lib/js/jquery.initialize.js"></script>
    </head>
    <body id="se">
    	<!-- begin header -->
    	<div id="header" class="clearfix">
    	{{header_se}}
    	</div>
    	<!-- end header -->
    
    	<!-- begin container -->
    	<div id="container" class="clearfix">
    <!-- begin sidebar -->
    <div class="sidebar">
    	<h2>[*menyrubrik*]</h2>
    	<div id="holder">
    <ul id="subnav" class="clearfix">
    	[*meny*]
    </ul>
    	</div>
    	<div class="bottom"></div>
    	<!-- begin promos -->
    	<div id="promos">
    		[*promos*]
    	</div>
    	<!-- end promos -->
    </div>
    <!-- end sidebar-->
    		<!-- begin article -->
    		<div id="content" class="article">
    			<h2>[*rubrik*]</h2>
    			<p class="ingress">[*ingress*]</p>
    			[*content*]
    [!dbTavlingSnippet!]
    [!eForm? &noemail=`true` &formid=`tavling_submit` &eFormOnBeforeMailSent=`dbTavlingSnippet` &tpl=`dbTavlingChunk` &report=`dbTavlingChunkReport`!]
    		</div>
    		<!-- end article -->
    	</div>
    	<!-- end container -->
    
    	<!-- begin footer -->
    	{{footer_se}}
    	<!-- end footer -->
    
    </body>
    </html>


    This worked when I used a different template with just the bare snippet call:
    [!dbTavlingSnippet!]
    [!eForm? &noemail=`true` &formid=`tavling_submit` &eFormOnBeforeMailSent=`dbTavlingSnippet` &tpl=`dbTavlingChunk` &report=`dbTavlingChunkReport`!]

    but it don’t work when I use the full template.
    Any ideas?
      • 25143
      • 2 Posts
      Nobody that knows what’s wrong with this?
      It works if I just use the snippet as a template instead of using the whole thing.

      It doesn’t work to just use eForm either (just for email) when I use the whole thing.
        • 7231
        • 4,205 Posts
        The only thing I could think of is if there is another element using the same ID as the form? Maybe this could cause a conflict? Try running the page with the form through a xhtml validator to see if there are any conflicts. Just a guess.

        The call and the code look OK amd if it works on a blank page but on with the template I am leaning towards a conflict.
          [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&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]