We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    I’ve installed FormIt and I’m considering using it as a way to validate searches. I have a very simple form right now (just a single field for a "searchterm"), and my FormIt call looks like this:

    [[!FormIt?
       &hooks=`search_my_table`
    ]]


    So literally, I’m doing nothing right now but having my custom Snippet "search_my_table" pick up the ringing phone after the form is submitted.

    In "search_my_table", I am successfully performing the search and I get some formatted $output... but I cannot seem to get this back to the browser! If I exit the Snippet prematurely, I can see the search results:

    print $output; exit;  // <-- this shows my search results


    Normally, I’d be accustomed to returning the $output:
    return $output;  // <-- with this option, the search results never show.


    The man page here http://rtfm.modx.com/display/ADDON/FormIt#FormIt-Customhookreturnvalues shows how to return an error message, e.g.
    $scriptProperties['hook']->errors['searchterm'] = 'Something went wrong';


    Presumably, these types of messages will percolate down to the placeholders on the page, e.g.

    <p>[[+fi.error.error_message]]</p>
    <span class="error">[[+fi.error.searchterm]]</span>
    


    What other methods are available to $scriptProperties[’hook’]? I don’t see any other examples here: http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks

    Thanks for any tips!
      • 26503
      • 620 Posts
      did you ever find a solution for this? I’m having a heck of a time setting up an advanced search on a custom table...

      -sean
        *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

        Sean Kimball CLP, CLS.
        Technical Director / Sr. Developer | BigBlock Studios
        ._______________________________________________.
        Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
        27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
        phone/fax: 905-426-5525
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Nope, I sure didn’t sad I ended up coding my own search forms.
          • 26503
          • 620 Posts
          Hi Everett;

          I’m having massive trouble with my search tools, I thought it would be easy [seems everything in modx that would be hard is a breeze & the simple stuff is a giant pain!]
          I need an advanced search & a user database search - so far I have the database table done & tried to get it integrated via the xpdo tutorials & examples, but the info in the docs that I really needed was labelled "coming soon" [excellent!]

          I can do all the php/sql snippet stuff to actually search & create results, what I’m banging my head on is passing the terms to the snippet [form it is not working!] and passing results back to the page....

          Can I convince you to share your code?

          -thanks
          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525