We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36426
    • 197 Posts
    Hi I'm trying to create a simple custom form in modx but I can't get it working right. It doesn't redirect and also doesn't show error messages etc...

    Can anyone please help me fix this thing up a little bit and improve it?

    [[!FormIt? &hooks=`email,redirect` &emailTpl=`NewBookFormTpl` &emailTo=`[email protected]` &redirectTo=`3` &validate=`name:required, email:required ` &validationErrorMessage=`Please check you have filled in all the information required.`]]</p>
    <p>[[!+fi.validation_error_message]]</p>
    <form class="NewBookForm" action="[[~[[*id]]]]" method="post">
    <h3>Name:</h3>
    <input id="name" type="text" name="name " value="[[+fi.name]]" />
    <p> </p>
    <h3>Email:</h3>
    <p><input id="email" type="text" name="email " value="[[+fi.email]]" /></p>
    <p> </p>
    <h3>Title of Publication:</h3>
    <p>(Final or provisional)<br /><input id="title" type="text" name="title " value="[[+fi.title]]" /></p>
    <p> </p>
    <h3>Genre:</h3>
    <p>(Business guide, autobiography, fiction etc)<br /><input id="genre" type="text" name="genre " value="[[+fi.genre]]" /></p>
    <p> </p>
    <h3>Reader:</h3>
    <p>(who are your target readers, and what will they get from the book eg. learning, inspiration, entertainment?)<br /><textarea id="reader" name="reader " rows="4" cols="55">[[+fi.reader]]</textarea></p>
    <p> </p>
    <h3>Function:</h3>
    <p>(For reading cover to cover or to dip into for information?)<br /><textarea id="function" name="function " rows="4" cols="55">[[+fi.function]]</textarea></p>
    <p> </p>
    <h3>Publication:</h3>
    <p>(Printed, eBook or both?)<br /><input id="publication" type="text" name="publication " value="[[+fi.publication]]" /></p>
    <p> </p>
    <h3>Links:</h3>
    <p>(A single, stand-alone book? Or linked to other books, a website etc?)<br /><input id="links" type="text" name="links " value="[[+fi.links]]" /></p>
    <p> </p>
    <h3>Our Help:</h3>
    <p>(What kind of help do you think you might like?)<br /><input id="help" type="text" name="help " value="[[+fi.help]]" /></p>
    <p> </p>
    <h3>Timescale:</h3>
    <p>(What is your deadline for completing your project?)<br /><input id="deadline" type="date" name="deadline " value="[[+fi.deadline]]" /></p>
    <p> </p>
    <h3>Other:</h3>
    <p>(Please add anything else about your project that you think might be helpful.)<br /><input id="other" type="text" name="other " value="[[+fi.other]]" /></p>
    <p align="right"><input type="submit" value="Send New Book Information Form" /></p>
    </form>


    and my tpl chunk:
    <p>Sent from Ebor Publishing New Book Form Information:</p>
    <br />
    <p>[[+name]] <[[+email]]> Wrote: <br />
    [[+title]]<br />
    [[+genre]]<br />
    [[+reader]]<br />
    [[+function]]<br />
    [[+publication]]<br />
    [[+links]]<br />
    [[+help]]<br />
    [[+deadline]]<br />
    [[+other]]<br />
    </p>


    Thanks for any help smiley
      Yorkshire UK based hosting provider: https://www.simulant.uk
      • 3749
      • 24,544 Posts
      If you're not getting the email, try installing the QuickEmail snippet to see if mail is working. If the FormIt email send fails, it probably doesn't execute the redirect hook.

      If you are, make sure the resource you're redirecting to is published and not hidden by any resource group ACL entries.

      Also, it probably doesn't matter, but take out the two spaces in:

      &validate=`name:required, email:required `


      >>>

      &validate=`name:required,email:required`




      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 36426
        • 197 Posts
        Hi many thanks Bob. For some reason now the form just shows my validation error message whatever I put in and doesn't send it.

        [[!FormIt? &hooks=`email,redirect` &emailTpl=`NewBookFormTpl` &emailTo=`[email protected]` &redirectTo=`3` &validate=`name:required,email:required` &validationErrorMessage=`There was an error - please check you have filled in all the information required.`]]


        and the form code:

        <span class="red"><p>[[!+fi.validation_error_message]]</p></span>
        <p> </p>
        <form class="NewBookForm" action="[[~[[*id]]]]" method="post">
        <h3>Name:</h3>
        <input id="name" type="text" name="name " value="[[+fi.name]]" />
        <p> </p>
        <h3>Email:</h3>
        <p><input id="email" type="text" name="email " value="[[+fi.email]]" /></p>
        <p> </p>
        <h3>Title of Publication:</h3>
        <p>(Final or provisional)<br /><input id="title" type="text" name="title " value="[[+fi.title]]" /></p>
        <p> </p>
        <h3>Genre:</h3>
        <p>(Business guide, autobiography, fiction etc)<br /><input id="genre" type="text" name="genre " value="[[+fi.genre]]" /></p>
        <p> </p>
        <h3>Reader:</h3>
        <p>(who are your target readers, and what will they get from the book eg. learning, inspiration, entertainment?)<br /><textarea id="reader" name="reader " rows="4" cols="55">[[+fi.reader]]</textarea></p>
        <p> </p>
        <h3>Function:</h3>
        <p>(For reading cover to cover or to dip into for information?)<br /><textarea id="function" name="function " rows="4" cols="55">[[+fi.function]]</textarea></p>
        <p> </p>
        <h3>Publication:</h3>
        <p>(Printed, eBook or both?)<br /><input id="publication" type="text" name="publication " value="[[+fi.publication]]" /></p>
        <p> </p>
        <h3>Links:</h3>
        <p>(A single, stand-alone book? Or linked to other books, a website etc?)<br /><input id="links" type="text" name="links " value="[[+fi.links]]" /></p>
        <p> </p>
        <h3>Our Help:</h3>
        <p>(What kind of help do you think you might like?)<br /><input id="help" type="text" name="help " value="[[+fi.help]]" /></p>
        <p> </p>
        <h3>Timescale:</h3>
        <p>(What is your deadline for completing your project?)<br /><input id="deadline" type="date" name="deadline " value="[[+fi.deadline]]" /></p>
        <p> </p>
        <h3>Other:</h3>
        <p>(Please add anything else about your project that you think might be helpful.)<br /><input id="other" type="text" name="other " value="[[+fi.other]]" /></p>
        <p align="right"><input type="submit" value="Send New Book Information Form" /></p>
        </form>


        I'm also trying to redirect the form to the same response id page as spform and include the code there for the thank you etc with spforms one. Is this possible and do I need some kind of response snippet call like spform has underneath on that page?

        Thanks for all your help.
          Yorkshire UK based hosting provider: https://www.simulant.uk
          • 3749
          • 24,544 Posts
          Try taking out the space in this:

          name="email "




          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 36426
            • 197 Posts
            Hi again. I've taken out that space along with all the other spaces in the name=" " references but still the form doesn't validate and produces an error. Thanks again to anyone who can help get this working...
              Yorkshire UK based hosting provider: https://www.simulant.uk
              • 3749
              • 24,544 Posts
              Sorry, I don't see anything that would keep it from working. The FormIt tag is above the form, right?

              What happens if you take out the &validate property?

              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                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