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 <a href="http://modxcms.com/extras/package/596">FormIt 1.0-alpha3</a> 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.

    - Optimized for Revo-2.0.0-beta5. This version will work only on 2.0.0-beta5 or later.
      • 22295
      • 153 Posts
      great script, thanks for it!

      Question regarding the validators and arrays, for example:
      In my form there is an input name=group[] type=checkbox.
      I would like to add validation in order to control the minSelectedItems and maxSelectedItem.

      How can validation be added to an input that has a name as array?

      a. if I add the validator to the original code ( name=group[]:testValidator ) - the validator is not called (but the PHP works as expected..)

      b. if i remove "[]" (i.e. name=group:testValidator) then the validator works. but PHP $_POST only see the last variable. it needs the [] to process the checkboxes.


      Any idea how to bypass this cleanly? (without breaking your code)
      thanks.
        • 28215
        • 4,149 Posts
        You’ll need to make the name:

        name="group:myValidator[]"


        with the brackets at the end. Unfortunately, the "required" hook doesnt work on checkboxes, for now, since that would require JS (which FormIt doesnt have plans of implementing at this time).
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 3749
          • 24,544 Posts
          Formit doesn’t seem to be setting any placeholders for use in the redirect page (e.g. Thank You page).

          It’s calling toPlaceholders() and the $fields array has the appropriate stuff in it, but nothing seems to be available on the redirect page. I can’t figure out why.

          I did a print_r($modx->placeholders) on the Thank you page and none of the Formit fields are there.
            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
            • 8522
            • 145 Posts
            I’d like to mix a custom hook with an Built-in hook using FormIt beta2

            my call
            [[!FormIt?
              &hooks=`myTest,redirect`
              &redirectTo=`6`
            ]]
            


            I can’t manage this to do the redirect. Do I have to return something special in the myTest hook (snippet)?

            BTW: is there a "Support/Comments for FormIt 1.0-beta2" ?

            thanks
              • 28215
              • 4,149 Posts
              Quote from: eerne at Jan 01, 2010, 11:00 AM

              I’d like to mix a custom hook with an Built-in hook using FormIt beta2
              I can’t manage this to do the redirect. Do I have to return something special in the myTest hook (snippet)?
              Try returning true.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 8522
                • 145 Posts
                Yep I tried <?php return true; ?> but it stays on the page. When I remove myTest from the &hooks it redirects properly. Possible a bug?
                  • 16545
                  • 358 Posts
                  How about compatibility with Evo 1.0.x ?
                    • 28215
                    • 4,149 Posts
                    Quote from: eerne at Jan 01, 2010, 12:03 PM

                    Yep I tried <?php return true; ?> but it stays on the page. When I remove myTest from the &hooks it redirects properly. Possible a bug?
                    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...

                    And then earlier in the calling function...
                    foreach ($hooks as $hook) {
                                $success = $this->load($hook,$fields);
                                if (!$success) return $this->hooks;
                                /* dont proceed if hook fails */
                    }
                    

                    So I’m not sure why it’s not working if you return true...
                      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                      • 28215
                      • 4,149 Posts
                      Quote from: labasus at Jan 02, 2010, 09:46 AM

                      How about compatibility with Evo 1.0.x ?
                      FormIt will most definitely not be compatible with Evo 1.0.x, nor do I have any plans to backport.

                      Someone else can definitely take up the code and backport it, though; but it would require a lot of work, as FormIt uses the new Revo API.
                        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com