We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for FormIt 1.0-alpha2 by splittingred.

    Brief Description:
    Automatically validate, parse and email forms. Redirect to thank you pages. Add your own hooks as Snippets to handle forms dynamically. Validate with custom Snippets.

    All is possible in FormIt, the new form processing Snippet for MODx Revolution 2.0.

    For Revolution 2.0.0-beta4 or later.

    Only for MODx Revolution 2.0-beta4 and beyond.

    Official documentation: http://svn.modxcms.com/docs/display/ADDON/FormIt

    Updates:
    - Added &errTpl, for a custom error wrapper for error messages.
      • 8522
      • 145 Posts
      Hi splittingred

      very nice solution, I think the Validation filters are a neat solution.

      One thing: Is it possible to add a class depending on the validation?

      <input type="text" name="username:required" value="[[+fi.username]]" class="" />
      
      <input type="text" name="username:required" value="[[+fi.username]]" class="required" />
      
      <input type="text" name="username:required" value="[[+fi.username]]" class="invalid" />


      This way one could make really nice forms with highlighted input fields. Maybe a [[+fi.username.error]] or similar placeholder could be added for this purpose?

      eni
        • 13247
        • 3 Posts
        Nice solution, it was realy simple to understand so that i was able to understand how to use it. I would realy like to use the solution.

        But what would you use the remove html tags function for. If someone want to put malicious script on my page they are probably also able to look at the HTML wondering, if the name="content:stripTags" can help them in some way. Hmm... what if they change the code (maby in firebug) to say name="content".

        So I would still need to remove the tags form the array returned form formit to use it on the site or view it in the browser, like webmail.
          • 28215
          • 4,149 Posts
          Quote from: eerne at Oct 20, 2009, 11:23 AM

          One thing: Is it possible to add a class depending on the validation?

          <input type="text" name="username:required" value="[[+fi.username]]" class="" />
          <input type="text" name="username:required" value="[[+fi.username]]" class="required" />
          <input type="text" name="username:required" value="[[+fi.username]]" class="invalid" />

          Sure; but I bet it’d be more like this:

          <input type="text" name="username:required" value="[[+fi.username]]" class="[[+fi.username.statusCls]]" />
          

          Or something. I’ll look into a solution.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 28215
            • 4,149 Posts
            Quote from: ivarne at Oct 23, 2009, 10:08 AM

            But what would you use the remove html tags function for. If someone want to put malicious script on my page they are probably also able to look at the HTML wondering, if the name="content:stripTags" can help them in some way. Hmm... what if they change the code (maby in firebug) to say name="content".
            Right; clever spammers could get around that. It’s there if you want it - if you want more robust spam/hacker prevention, you can add a custom snippet as a Hook to use PHP’s strip_tags on your fields.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 13247
              • 3 Posts
              A better solution would have been if there was an option to the snippet that stated wich felds should allow tags (and probably witch), because I did not relise the flaw from reading the description and most of the user suplied data should not include html tags.

              It might look a bit like this?

              [[FormIt ? 
                  &hooks=`email,saveform,redirect` 
                  &emailTpl=`myEmailChunk` 
                  &emailTo=`[email protected]` 
                  &redirectTo=`2`
                  &allowTags=`content(<p><a><br>),description(<br>)`
              ]]     
              


              This will force people using the snippet to realy consider what to allow thir users to do. And my saveform snippet can save the validated data, not revalidate it.
                • 28881
                • 18 Posts
                Is there an option to prevent validation chaining? i.e. only show the relevant validation message - so if a field is empty, only show the "required" message. If it’s invalid, show the "invalid email" message (for example)? I’m sure this can be achieved with a snippet - I just wanted to know if it was possible out of the box?
                  • 28215
                  • 4,149 Posts
                  sunwukung: No, not at this time, though that’s a good feature request, can you file it here: http://github.com/splittingred/FormIt/issues/
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com