We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    The dutch language file for eForm 1.4.3 can be found here
      • 4873
      • 11 Posts
      I use eForm (Version 1.4 with modx 0.9.6) for a contact form. In the same page I’ve got another form to subscribe to a newsletter, which appears before the contact form. Here’s the problem: everytime I try to submit the contact form, I end up submitting the newsletter registration form. I’ve tried several things:

      - distinguishing each form by using a distinctive id and name;
      - then using a javascript submission button to specify more clearly which form I’m submitting, ie

      javascript:document.forms.ContactForm.submit(); for the contact form and
      javascript:document.forms.NLreg.submit(); for the registration form

      but none of the above mentioned seems to work, the eform form keeps submitting the NL registration form first. Anyone has an idea no how to make the forms work independently?

      Any hint will be highly appreciated!
        • 30223
        • 1,010 Posts
        Give us your form templates and the snippet calls to start with... Without them there’s not much I can say about this, besides perhaps trying to add <input type="hidden" value="YourFormId" /> to each of your forms.

        The formid is used for distinquishing between forms on the same page. eForm should pick that up form <form id="yourFormId" ... > but it doesn’t hurt to add the hidden field.

        Are your forms nested perhaps?
          • 25420
          • 74 Posts
          Hi,

          I’m developing a site with front end being Flash (I’m not doing the Flash).
          The flash guy has made a Flash form I need to process. Can eForm work for me ? I’m not sure it’s possible to send some $_POST variables directly to the page containing the snippet. It looks like the snippet is trying to render the tpl chunk form first, which I don’t want.

          thanks,
          Seb

            • 30223
            • 1,010 Posts
            eForm’s purpose is mainly to make it easy and relatively save to use HTML forms. However as long as the flash form works with POST instead of GET you could use a trick to do what you want I think..., that is with a small hack to eForm..

            Create a simple HTML form with exactly the same fields as are in the flash form. This is necessary so that eForm can parse the info it needs. This could simply be a list of the input fields within form tags. You wouldn’t need any extra markup.
            Something like:

            <form id="myFlashForm" >
            <input type="text" name="field1" eform="Field One:text:1:Some custom error message" />
            <input type="text" name="field2" eform="Field Two:date:1:Another custom error message" />
            <etcetera ...>
            </form>
            


            Now we need to replace this form with the actual flash form when eForm tries to display things... The eFormOnBeforeMerge event is the best place to do this, except that as it is, within this event you can not make changes to the form template. For this we need a small hack in eForm itself (assets/snippets/eform/eform.inc.php)

            Find this bit of code:
            //<?php
               # invoke OnBeforeFormMerge event set by another script
               if ($eFormOnBeforeFormMerge) {
                  if( $isDebug && !function_exists($eFormOnBeforeFormMerge))
                        $fields['debug'] .= "eFormOnBeforeFormMerge event: Could not find the function " . $eFormOnBeforeFormMerge;
                     else
                        if ($eFormOnBeforeFormMerge($fields)===false) return;
               }
            //?>
            


            and replace it with:

            //<?php
               # invoke OnBeforeFormMerge event set by another script
               if ($eFormOnBeforeFormMerge) {
                  if( $isDebug && !function_exists($eFormOnBeforeFormMerge))
                        $fields['debug'] .= "eFormOnBeforeFormMerge event: Could not find the function " . $eFormOnBeforeFormMerge;
                     else
            //the change is in the following line...
                        if ($eFormOnBeforeFormMerge($fields, $tpl )===false) return;
               }
            //?>
            


            Next we need an extra chunk with the code for the flash form that includes a placeholder for validation messages and any extra bits (parameters) that the flash form may need. It depends how the flash form is set up. How does it work with invalid forms? Does it retain the values entered? If so you may need to get clever with some additional placeholders. Lets say we call this chunk simply ’flashFormChunk’

            [+validationmessage+]
            <object ...>
               <param src="flashForm.swf" />
               <param ... />
               <... etcetera />
            </object>
            


            Now it’s time for the event function, which you create in a separate snippet.
            //<?php
            function formMergeEvent( &$fields, &$tpl ){ //both params as reference
               //load the extra chunk in place of $tpl
               $tmp = efLoadTemplate('flashFormChunk');
               if($tmp) $tpl = $tmp;
               else die("Could not load the 'flashFormChunk'");
               
               return true
            }
            //?>
            


            Lastly you’ll have to add this event to the snippet call and make sure the event function snippet is loaded before eForm.
            [[myEventFunction]]
            [!eForm? &eFormOnBeforeFormMerge=`formMergeEvent` &formid=`myFlashForm` !]
            



            There is one more rather important requirement for the flash form!!! The flash form needs to have a hidden field called ’formid’ with the same value as you set in the &formid snippet parameter! Without this you have no chance of any of this working (unless you want to hack into the eForm code quite a bit...)

            Hope this sends you in the right direction...
              • 6792
              • 11 Posts
              To avoid unnecessary scattering of replies I’m removing this cross-post and its reply. Please see this post http://modxcms.com/forums/index.php/topic,16848.msg106766.html#msg106766.. (and please do not cross-post your questions!)
                • 25420
                • 74 Posts
                Hi Toby,

                just to let you know that it did work very well, thanks ! the formid is indeed the key. I didn’t need to hack any of the snippet as all I needed was eform to receive the data and send them into an email. We even managed to send an attached file through the flash form.

                Cheers,
                Seb
                  • 30223
                  • 1,010 Posts
                  Good to hear! Care to share the process you went through, especially what your flash programmer had to do? I’m sure this would be a nice addition to the wiki.
                    • 25420
                    • 74 Posts
                    done : http://wiki.modxcms.com/index.php/EForm#Examples

                    feel free to correct my english embarrassed
                      • 22897 ☆ A M B ☆
                      • 209 Posts
                      I’ve got an eform form with a select box, and no validation rules set up:
                      <select name="title" id="title">
                                  <option value="">select title</option>
                                  <option value="Mr">Mr</option>
                                  <option value="Mrs">Mrs</option>
                      </select>


                      No validation rule should mean when I don’t select a title (ie when ’select title’ is selected) there is no error.

                      However when I do not select a title it gives the error
                      title » Incorrect value

                      What can I do to stop this error? A work-around is to insert value="." for the default option... but I don’t want any value set.
                        MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!

                      This discussion is closed to further replies. Keep calm and carry on.