We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39346
    • 4 Posts
    Hello everyone!
    I need to have all values on the form to be preserved on clicking the SUBMIT button.
    It works when using the POST method but when using the GET method all fields get cleared.
    Also all checkboxes get unchecked and I need them.
    Please help resolve this issue!

    [[!FormIt?
        &clearFieldsOnSuccess=`0`
    ]]
     
    <h2>Contact Form</h2>
     
    <form action="[[~[[*id]]]]" method="get" class="form">
     
        <label for="name">
            Name:
            <span class="error">[[!+fi.error.name]]</span>
        </label>
        <input type="text" name="name" id="name" value="[[!+fi.name]]" />
     
        <label for="email">
            Email:
            <span class="error">[[!+fi.error.email]]</span>
        </label>
        <input type="text" name="email" id="email" value="[[!+fi.email]]" />
     
        <label for="subject">
            Subject:
            <span class="error">[[!+fi.error.subject]]</span>
        </label>
        <input type="text" name="subject" id="subject" value="[[!+fi.subject]]" />
     
        <label for="text">
            Message:
            <span class="error">[[!+fi.error.text]]</span>
        </label>
        <textarea name="text" id="text" cols="55" rows="7" value="[[!+fi.text]]">[[!+fi.text]]</textarea>
     
     
        <label>
            Numbers:[[+fi.error.numbers]]
            <select name="numbers" value="[[!+fi.numbers]]">
                <option value="">Select an option...</option>
                <option value="one" [[!+fi.numbers:FormItIsSelected=`one`]]>One</option>
                <option value="two" [[!+fi.numbers:FormItIsSelected=`two`]]>Two</option>
                <option value="three" [[!+fi.numbers:FormItIsSelected=`three`]]>Three</option>
            </select>
        </label>
     
        <label>
            Colors:[[!+fi.error.colors]]
            <input type="hidden" name="colors[]" value="" />
        </label>
        <ul>
          <li>
            <label><input type="checkbox" name="colors[]" value="red" [[!+fi.colors:FormItIsChecked=`red`]] /> Red</label>
          </li>
          <li>
            <label><input type="checkbox" name="colors[]" value="blue" [[!+fi.colors:FormItIsChecked=`blue`]] /> Blue</label>
          </li>
          <li>
            <label><input type="checkbox" name="colors[]" value="green" [[!+fi.colors:FormItIsChecked=`green`]] /> Green</label>
          </li>
        </ul>
     
        <br class="clear" />
     
        <div class="form-buttons">
            <input type="submit" value="Send Contact Inquiry" />
        </div>
    </form>
    
    • Why do you need to use GET?
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 39346
        • 4 Posts
        I have a form for choosing products based on their parameters.
        What I need is to have filled in parameters preserved after the search is complete in order to be able to correct them and click on "submit" again.
        There are also pages with links leading to my page with an additional parameter. For instance, 123.com?rtype=3. These pages display products with a specified value of the TV rtype.
        I'm also planning to use links with certain values of GET for certain types of products for SEO.
        I process all parameters using my snippet and pass them to getPage.
        It, too, uses GET for pagination. That is when clicking on page 2, all values of GET are reset.

        In other words I need FormIt only for saving values after submitting the form. It works fine with POST but not GET.
        It's not necessary to use FormIt specifically. I just need a way to preserve all values of INPUTs after submission.
          • 3749
          • 24,544 Posts
          You might be able to use a preHook or postHook with FormIt to set the $_POST values from the $_GET parameters. I'm not sure it would work.
            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