We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23491 ☆ A M B ☆
    • 1,056 Posts
    You might want to check ’eform.inc.php’ to make sure that it isn’t hijacking the functionality...if that make sense? Basically what bS said...
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
      • 30223
      • 1,010 Posts
      Quote from: rthrash at Oct 18, 2006, 05:57 PM

      Another fun challenge today... I’m trying to set the default values of some fields in an eform to a logged in webuser’s profile details. I can’t get it to work at all. For example, I tried to set it to the logged in users name via PHx:

      value="[+phx:userinfo=`username`+]"


      This would indeed not work as eForm merges all placeholders first and will clean up any leftover placeholders...


      and by using [[GetUserName]]:

      $pid = $modx->getLoginUserID();
      $data = $modx->getUserInfo($pid);
      
      return $data['fullname'];


      with the following field:

      value="[[GetUserName]]"


      Ideas ... or is it just a wonky bug I’ve run into?

      This should actually work I would have thought. see below...

      Another way you could achieve this maybe is using the new &sessionVars parameter. If your GetUserName snippet call is placed on the page before eForm and it would set for instance $_SESSION[’defaultEmail’] (instead of returning the value) this would set the $fields array in eForm.

      [[GetUserName]]
      [!eForm sessionVars=`defaultEmail` ... !]


      The form would then need a placehoder [+defaultEmail+] like this:
      <input type="text" name="email" value ="[+defaultEmail+]" /> 


      Edit: You may also need to set &postOverides=`1` as perhaps otherwise they wouldn’t be able to change the value (ass session values take precedence normally)

      Quote from: bS at Oct 18, 2006, 06:04 PM

      Just a wild guess is that MODx tags IN form tags will not get parsed because eForm parses the template before MODx can get to it.

      eForm (1.4) doesn’t actually fully parse the form (with eFormParse) the first time the form is displayed (but it does strip the ’eform attributes’). It only fully parses the form on POST and replace any [+placeholders+]. You should be able to have snippet calls in the form like this.

      <input type="text" name="email" value="[[getUserName]]" />


      I just tried this with a snippet trhat simply return a hard-coded value (i.e. return "[email protected]"; ) and for me that worked.

      @pixelchutes Thanks for your digging... I’ll look into some of these issues a later when I have a bit more time.
        • 25663 MODX Staff
        • 12,272 Posts
        Ugh... multiple stupid mistakes on my part but this should help folks figure it out in the future:

        1) You can put cached snippet calls in the eForm forms... they have to be uncached calls.
        2) Use the right API: getWebUserInfo happens to return the webuser (not manager user) info and would’ve kept me from wasting a bunch of time otherwise.

        Working exactly as expected now; sorry for wasting your time. tongue
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 22221
          • 283 Posts
          I’ve tested eForm with the example site in 0.9.5 beta 5.
          I notice there is an error if I change the language in the site configuration an if there isn’t the corresponding language file in the snippet folder.

          I think some code to test the existing of the file like Ditto does should be added.
            • 30223
            • 1,010 Posts
            Thanks for spotting that.. Will do!
              • 22221
              • 283 Posts
              One other feedback : I’m a French user and when I use special caracters they are not well managed.
              Is it possible to add a way to eForm to specify the charset to use or better to use the charset set in the configuration panel of the manager ?
                • 6425
                • 23 Posts
                I thought it was fixed. Now my form will come up, but when I submit I get this error:

                « MODx Parse Error »
                MODx encountered the following error while attempting to parse the requested resource:
                « PHP Parse Error »

                PHP error debug
                Error: Invalid argument supplied for foreach()
                Error type/ Nr.: Warning - 2
                File: /var/www/WEVmodX/modx-0.9.2.1/assets/snippets/eform/eform.inc.php
                Line: 651
                Line 651 source: foreach ($attributes as $k => $v)

                Parser timing
                MySQL: 0.0129 s s (15 Requests)
                PHP: 0.1351 s s
                Total: 0.1480 s s
                  • 23491 ☆ A M B ☆
                  • 1,056 Posts
                  I wish I knew where to go RE: my redirect issues. Starting to seem like it is only impacting me?

                  I will do a fresh install of latest trunk revision, as well as eForm code and let you know.
                    Mike Reid - www.pixelchutes.com
                    MODx Ambassador / Contributor
                    [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                    ________________________________
                    Where every pixel matters.
                    • 23491 ☆ A M B ☆
                    • 1,056 Posts
                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »
                     
                    PHP error debug
                      Error: 	Invalid argument supplied for foreach()	 
                      Error type/ Nr.: 	Warning - 2	 
                      File: 	/www/assets/snippets/eform/eform.inc.php	 
                      Line: 	651	 
                      Line 651 source: 	foreach ($attributes as $k => $v) 	 
                     
                    Parser timing
                      MySQL: 	0.0015 s	(6 Requests)
                      PHP: 	0.0847 s	 
                      Total: 	0.0862 s
                    


                    I also get this error...on my test (local) site, Windows (Apache), no FURL...

                    Weird thing is that, out of the box, I am getting the same REDIRECT issue.

                    NOTES:
                    1. Current trunk MODx install 0.9.5 beta 5 rev 1743
                    2. Install eForm 1.4 (final) from the repository. (Update snippet code, and overwrite /assets/eform dir)
                    3. Create a published, secondary test page.
                    4. Add the following snippet call somewhere to the "Minimal Template":

                    [!eForm? &formid=`contact` &to=`[email protected]` &tpl=`contactform` &report=`contactreport` &thankyou=`contactthanks` &subject=`Website feedback`!]
                    


                    5. Create the needed chunks:

                    HOLD EVERYTHING!!!!

                    As I am preparing this post, I’m realizing that I don’t want to submit my long, contact form. So, I create a stripped down, more simple version ...easier to read, etc

                    I tested it out to make sure it all worked. (tested on my Live site, not even the local test)

                    Sure enough, worked like a champ! NO REDIRECT!

                    So, I wonder why a complex form like mine would cause an unwanted redirect?

                    An excerpt:

                    		<div class="form-row">
                    			<div class="field-label"><label for="email">Email Address</label>:</div>
                    			<div class="field-label"><input name="email" id="email" class="required validate-email" onBlur="this.value=this.value.replace( /\s+/g, '' );" size="30" maxlength="50" title="Please enter your email address." value="[+email+]" eform=":email:1" /></div>
                    		</div>
                    


                    NOTES:
                    - I use prototype.js for some nice client-side validation effects, hence the class values
                    - This excerpt alone does not result in the redirect issue I am experiencing.

                    UPDATE:
                    I created a new chunk, renaming my old. I slowly started including elements of the original chunk until I was able to reproduce the error. I eventually added the Entire original chunk! ...only this time, No Redirect Error? No way...I cannot think of what’s happening here. I have deleted the original chunk...knocked another one off my massive eForm list. ha!

                    @TobyL-- I hope you know this is all very constructive criticism. I believe in this tool and appreciate the work that has been put into it. Mainly, I do not want to spend the time to create my own smiley Once I get this eForm using the function for db-Insertion (+noemail), I’ll be set!! Great work!
                      Mike Reid - www.pixelchutes.com
                      MODx Ambassador / Contributor
                      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                      ________________________________
                      Where every pixel matters.
                      • 23491 ☆ A M B ☆
                      • 1,056 Posts
                      Quote from: danderson at Oct 19, 2006, 12:12 PM

                      I thought it was fixed. Now my form will come up, but when I submit I get this error:

                      « MODx Parse Error »
                      MODx encountered the following error while attempting to parse the requested resource:
                      « PHP Parse Error »

                      PHP error debug
                      Error: Invalid argument supplied for foreach()
                      Error type/ Nr.: Warning - 2
                      File: /var/www/WEVmodX/modx-0.9.2.1/assets/snippets/eform/eform.inc.php
                      Line: 651
                      Line 651 source: foreach ($attributes as $k => $v)

                      Parser timing
                      MySQL: 0.0129 s s (15 Requests)
                      PHP: 0.1351 s s
                      Total: 0.1480 s s

                      I discovered my error behind receiving the above error:

                      ...
                      <option value=Greenland (Pituffik)"">Greenland (Pituffik)</option>
                      ...
                      


                      ...looks like the value wasn’t properly nested in the quotes, causing it to Bomb!
                        Mike Reid - www.pixelchutes.com
                        MODx Ambassador / Contributor
                        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                        ________________________________
                        Where every pixel matters.

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