We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25276
    • 8 Posts
    Here’s a newbie question about snippets.

    I have the following form that I would like to convert to a snippet (the snippet makes a web service call):

    <form action=" [(site_url)]controller/controller.php" method="post">
    <table>
    <tbody>
    <tr>
    <td>First name</td>
    <td><input name="firstName" type="text" /></td>
    </tr>
    <tr>
    <td>Last name</td>
    <td><input name="lastName" type="text" /></td>
    </tr>
    <tr>
    <td>Email</td>
    <td><input id="ssoEmail" name="email" type="text" /></td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="Continue" /></td>
    </tr>
    </tbody>
    </table>
    </form>

    I have written a snippet that contains the php code that is in controller.php. I’m trying to reference the snippet as follows:

    <form action="[[controller]]" method="post">
    * * *
    </form>

    However, ModX returns the action empty.

    Any help is appreciated. Thanks!

      • 30223
      • 1,010 Posts
      I’m assuming (or at least I hope so) that this snippet outputs a url of some sort yes?

      Try putting the snippet somewhere outside any html tags to start with so you can see it’s output without having to do a view source. Then try calling the snippet uncached i.e. [!controller]]
        • 22303 MODX Staff
        • 10,725 Posts
        If you want to execute the snippet and get access to the form POST, you’ll need to place this snippet on a page in MODx, probably without a template, and set to the appropriate content-type for whatever the web service is returning. Then you’ll just set the action to the page link, i.e. [~45~] if the document with that snippet had document id 45.
          • 25276
          • 8 Posts
          Thanks for your help!

          The action returns a url based upon the form post.

          I’ll give your suggestions a try.
            • 3749
            • 24,544 Posts
            Quote from: robhicks at Sep 26, 2007, 04:59 PM

            Thanks for your help!

            The action returns a url based upon the form post.

            I’ll give your suggestions a try.

            Instead of using something like [~45~] , you can also just put the name of the MODx document that contains your second snippet call. That’s good if you might ever use the same code on another site where the document number might not be the same.

            Bob
              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