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!
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]]
-
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.
Thanks for your help!
The action returns a url based upon the form post.
I’ll give your suggestions a try.
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