We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8522
    • 145 Posts
    Quote from: splittingred at Jan 03, 2010, 11:21 PM

    Possibly; it should work if you return true...I’ll do some debugging on it this week to figure that out. The code is:

    $success = $snippet->process($properties);
    ...
    if (is_array($success) && !empty($success)) {
        $this->errors = array_merge($this->errors,$success);
        $success = false;
    } else if ($success !== true) {
        $this->errors[$hook] .= ' '.$success;
        $success = false;
    }
    return $success;
    

    This allows you to return either a string error message, or an array of error messages...
    ...
    So I’m not sure why it’s not working if you return true...

    Thanks for pointing me to the code in charge. I found something now, when the snippet returns true, for some reason it passes $success !== true. It seems to work when exchanging !== with !=
    not sure what is happening here.

    Now I’m trying to run two hooks (snippets), where the first one should modify some $fields and the second one display the modifications that the first hook made. Should this be possible at the moment?

    What is the difference between $scriptProperties[’fields’] and $fields?

    Thanks so much, this is going a very nice direction!
    eni
      • 22295
      • 153 Posts
      You could also add you own validators directly and just call that one hook.
      The validators validate and manipulate the POST, then - pass it on as $fields to the hook(s).
      look at: http://svn.modxcms.com/docs/display/ADDON/FormIt

      and also at this file: fivalidator.class.php
      look at strip or stripTags validators code, it’s more or less your direction.
        • 8522
        • 145 Posts
        Hi oori

        Actually I got everything working, with a custom hook that writes data to a db (with xdpo) and a builtin redirect hook, that only works with the modification !== to != as posted earlier.

        Quote from: oori at Jan 04, 2010, 07:33 AM
        You could also add you own validators directly and just call that one hook.
        Yes I’m already using the Built-In Validators, works like a charm! I’ll definitely will have a look at custom validators too.
        Quote from: oori at Jan 04, 2010, 07:33 AM
        The validators validate and manipulate the POST, then - pass it on as $fields to the hook(s).
        look at: http://svn.modxcms.com/docs/display/ADDON/FormIt
        Thanks for clarification. I guess I was just a bit confused, because I didn’t find information about "$fields" and that both $fields and $scriptProperties are available in the hook and seem to contain the same data.
          • 28215
          • 4,149 Posts
          I’ve released a new version of the package to address the !== issue.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 34193
            • 330 Posts
            Having looked at http://svn.modxcms.com/docs/display/ADDON/FormIt I read

            The email hook

            The email hook will email out your form contents to any email(s). It requires the following properties to be passed into the snippet call:

            emailFrom Optional. If set, will specify the From: address for the email. If not set, will first look for an `email` form field. If none is found, will default to the `emailsender` system setting.


            I took this to mean that if I don not use emailFrom property and included
            <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />

            in my form then the email would be sent using the details in this field as the from address.

            Upon testing my form the email is sent but arrives with nothing in the from this means that I can not reply to the email. If it set this property then all emails arrive from the email address i set it to as would be expected but this means if the client hits reply it goes to the address set in the property not the address of the person filling in the form which is what i want to happen.

              • 20711
              • 5 Posts
              I’m having similar issues - the emails are being sent but there is no content (message) in the body. None of the fields in the form (name, email, subject, text) are being sent. The email arrives from: (unknown sender) with subject: (no subject).

              Also, what does the `emailTpl` placeholder do? Do I need a chunk called `myEmailChunk`? It’s used in the example at http://svn.modxcms.com/docs/display/ADDON/FormIt+Example+1+-+Contact+Page but is not mentioned in the documentation at http://svn.modxcms.com/docs/display/ADDON/FormIt

              I’ve been banging my head on this for hours now... >:(
                • 22570
                • 2 Posts
                Same here, I´m desperate for a solution to this. How is the emailTpl chunk supposed to look like? The messages go through, but contains nothing more than the subject..
                Please help huh
                  • 3749
                  • 24,544 Posts
                  Add these:

                  &emailTpl=`myEmailChunk` &emailUseFieldForSubject=`1`


                  Content of myEmailChunk:

                  This is the Formit Email Chunk.
                  
                  <br />[[+name]] ([[+email]]) Wrote: <br />
                  
                  [[+text]]


                  It’s working for me (though it took a while to figure out what the placeholders should be). Note: the parentheses around the email tag are unnecessary and are rendered literally in the output.
                    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
                    • 3749
                    • 24,544 Posts
                    FYI -- here is an example that uses Formit with SMTP via your email account at Gmail to send the messages:

                    [[FormIt?
                       &hooks=`email,redirect`
                       &emailUseFieldForSubject=`1`
                       &emailTpl=`myEmailChunk`
                       &emailTo=`[email protected]`
                       &redirectTo=`123`
                       &smtpEnabled=`1`
                       &smtpAuth=`1`
                       &smtpHost=`smtp.gmail.com`
                       &smtpUsername=`[email protected]`
                       &smtpPassword=`your_gmail_password`
                       &smtpPort=`465`
                       &smtpPrefix=`tls`
                    ]]


                    Note that Gmail will change the "From" address to your gmail email address. That’s why I put [[+email]] in the Tpl chunk. Otherwise, you wouldn’t have the sender’s email address and could not reply.
                      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
                      • 22570
                      • 2 Posts
                      Great, got it working now! grin
                      Thanks BobRay!