We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8343
    • 6 Posts
    Hi, I hope this is not a repeat. I tried posting several times and I was getting a 401 error. Anyway, here is my post:
    Hello, I’m trying to learn how to save the data of a submitted form and fill the form again in case a validation error occur after the user submits the form.
    I’m using Modx Revo on this one: http://www.expresssignproducts.com/register.html
    Here is a sample of the code:
    <tr bgcolor="#fffacd">
    <td align="right">City <span class="RequiredField">*</span></td>
    <td align="left">
                          <label>
                            <input id="City" maxlength="25" name="city:required" size="25" type="text" value="[[+city]]" />
                          [[+error.city]]                    </label>
                          </td>
    </tr>
    <tr>
    <td align="right">Province/State</td>
    <td align="left"><label>
                            <select id="Province" name="state">
                                                        <option value="AL">Alabama</option>
                                                        <option value="AK">Alaska</option>
                                                        <option selected="selected" value="AB">Alberta</option>
                                                        <option value="AZ">Arizona</option>
                                                         <!-- more options -->
                                                      </select>
                          </label></td>
    </tr>
    
    

    The problem I have is that when there’s a validation error, the text fields (like city) are filled out again, but not the choice fields: so, "Province" defaults to Alberta again, regardless what the user chose.
    How can I extend this feature to all fields?

    Regards,
    Eduardo
      • 8609
      • 607 Posts
      [UNTESTED]: Try adding the value attribute to your select

      <select id="Province" name="state" value="[[+state]]">....
        • 8343
        • 6 Posts
        Hi, I tried your suggestion, einsteinboi, but it didn’t work.
        Finally this one comes close:

        <select id="Province" name="state">
                                                            <option value="AL">Alabama</option>
                                                            <option value="AK">Alaska</option>
                                                            <option selected="selected" value="[[+state]]">[[+state]]</option>
                                                            <option value="AB">Alberta</option>
        
                                                            <option value="AZ">Arizona</option>
                                                             <!-- more options -->
                                                          </select>
        
        

        This saves the form data, but the selected is actually a blank item at first.
        Thank you, anyway.