We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17851
    • 213 Posts
    I’ve read this post:

    http://modxcms.com/forums/index.php/topic,22072.0.html

    and searched the forums but I haven’t found exactly what I need.

    I’m using eForm as a set of search/filter fields (both text and dropdowns) that I’m passing to custom DB table. Results are displayed on the same page. I’m trying to "keep/save" the values typed in by the user once they hit the results page. I’ve got the text fields working by:

    <input type="text" name="mytextfield" value="[+mytextfield+]" />

    But how would I do the same thing with a dropdown? The following obviously doesn’t work:

    <select name="myselfield" value="[+myselfield+]">....</select>

    I’ve got a function defined for eFormOnBeforeFormParse event. But it only sets the value of $fields[’myselfield’].

    Any suggestions? Thanks.
      Mark Macatee
      President
      Power 10 Solutions
      http://www.power10solutions.com
      • 17851
      • 213 Posts
      I figured this out. You need two components:
      1. the #LIST in the eform attribute
      2. the [+attr:value+] for each option element

      <select name="city" eform="City:listbox:0::#LIST Austin,Dallas,Houston">
      <option value=""></option>
      <option value="Austin" [+city:Austin+]></option>
      <option value="Dallas" [+city:Dallas+]></option>
      <option value="Houston" [+city:Houston+]></option>
      </select>


      The [+city:Dallas+] gets replaced with ’selected="selected"’ if the option value matches the submitted field value. Also works for checkbox and radio (replacing "listbox" in eform attribute with checkbox or radio as necessary)
        Mark Macatee
        President
        Power 10 Solutions
        http://www.power10solutions.com