<![CDATA[ Calling a snippet from a form [frontend] - My Forums]]> https://forums.modx.com/thread/?thread=33459 <![CDATA[Re: Calling a snippet from a form [frontend]]]> https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-548900 inyerman Feb 23, 2017, 01:01 PM https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-548900 <![CDATA[Re: Calling a snippet from a form [frontend]]]> https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184177 ]]> zombiemx Jul 22, 2006, 10:26 AM https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184177 <![CDATA[Re: Calling a snippet from a form [frontend]]]> https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184176
<form name="myform" action="[~69~]" method="post"> 
<input type="text" name="firstname" />
<input type="submit" name="submit" value="submit"/>
</form>


if the snippet is in document what’s id is 69. Or if you have the snippet on the same document, you don’t have to supply the action attribute, or put action="[~[*id*]~]".

Then in the snippet do like this to get the input from form:

if($_POST["submit"]) {
   $fld_firstname = $_POST["firstname"];
   ...
}
]]>
doze Jul 22, 2006, 08:52 AM https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184176
<![CDATA[Re: Calling a snippet from a form [frontend]]]> https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184175
You can just use the eForm snippet with the email option set to 0. It will automatically process your form and do validation checks as well.]]>
sottwell Jul 22, 2006, 08:44 AM https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184175
<![CDATA[Calling a snippet from a form [frontend]]]> https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184174 But I don’t have a clue for this issue at the moment:
I would like to integrate a <form> element with some input-fields and a submit button in my template (or as a chunk, respectively).
How can I attach a snippet to the "submit"-event, so that the snippet is executed when the user clicks the "submit"-button?
I want to implement the functionality as a snippet, since this seems to be the most compatible and organized way to do it.]]>
zombiemx Jul 22, 2006, 08:07 AM https://forums.modx.com/thread/33459/calling-a-snippet-from-a-form-frontend#dis-post-184174