We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14772
    • 14 Posts
    Ok, I have been trying to implement your suggestions from a previous post, but it is not working. So how do I implement this in Modx??

    Here is my setup:

    I have my HTML form contained in a snippet called html_form, and I have this formed contained in my page like this: {{html_form}}. Now I have in the snippet section of modx a snippet named form_proc which connects to the database and all of that. So inside the html_form, under the action= what kind of syntax do I use to reference the form_proc in the snippets section of modx?


    Thanks in advance!

    PS. I have tried [~form_proc~], [[form_proc]], and [form_proc] - none of which worked.
      • 29132
      • 1 Posts
      Hi!
      If html_form is a snippet then u should call it by [!html_form!] or [[html_form]] not {{ }} because its a chunk call. I’m wondering why you don’t use eForm snippet its really easy and very flexible? huh When u call snippet in snippet u must use [[html_form? &parameter=`[!other_snippet!]`]] or diffrent way first [! !] and then [[ ]] this topic was on forum some time ago and i don’t remember it well smiley but u must switch these ways. Unless html_form is template chunk then ur call for it is OK and u use in action any of snippet calls. I hope I’m not wrong(and i understood ur problem in right way). Sorry for my , little rusty English smiley
      PeAcE!! grin grin
        • 4041
        • 788 Posts
        You can combine all that into one snippet may be the easiest route, try something like this:
        Take the format below and create your own snippet, name it whatever and call it on a document like so:

        [!ExampleForm!]

        <?php
        /*  Example form snippet  
             -> if the submit button is pressed, the form is processed and result is shown,
                 otherwise show the form
        */
        $output ="";
        
        if(isset($_POST['submit'])){
        // add your form process code here in the $output variable
             $output .="<div align='center'>Welcome ".$_POST['webusername'].", you are logged in...</div>";
        }else{
        // add your form code here in the $output variable
             $output .="<form id='loginForm' name='loginForm' method='post' action='[~12~]'>
            <table width='300' border='0' align='center' cellpadding='2' cellspacing='0'>
              <tr>
                <td width='112'><b>Login</b></td>
                <td width='188'><input name='webusername' type='text' class='textfield' id='webusername' /></td>
              </tr>
              <tr>
                <td><b>Password</b></td>
                <td><input name='password' type='password' class='textfield' id='password' /></td>
              </tr>
              <tr>
                <td> </td>
                <td><input type='submit' name='submit' value='Login' /></td>
              </tr>
            </table>";
        }
        return $output;
        ?>


        In this example snippet the action=’[~12~]’ spot, the 12 is the ID of the document itself which contains this snippet code, since in this example the form and processor are on the same page.
          xforum
          http://frsbuilders.net (under construction) forum for evolution
          • 14772
          • 14 Posts
          Yeah, actually html_form is a chunk, sorry for that misprint!