We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8822
    • 203 Posts
    Hello there, i am using MODX Revo 2.2.0 and FormIt 2.0.3. I have about 10 pages that use FormIt for data entry, with anywhere between 15-40 fields. These pages are currently taking about 10 seconds to load which the customer is not going to be happy about! A number of these fields are drop down selection boxes which i believe maybe the problem - removing these does seem to increase the speed of the pages. The problem is that i have to use selection drop downs. Any ideas, suggestions or alternatives? Many thanks
      • 4172
      • 5,888 Posts
      some examples of your dropdowns?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8822
        • 203 Posts
        Hi Bruno, thanks for responding. At the most simplist, an example dropdown is:
        <td align="right">
          <label for="gender" class="formlabels [[!+fi.error.gender:notempty=` error`]]">Gender:</label>:</td>
        <td align="left">
          <select name="gender" class="forminputs [[!+fi.error.gender:notempty=` error`]]" id="gender" tabindex="6" value="[[+fi.gender]]">
            <option value="" selected>Please Select</option>                   
            <option value="Female" id="Female" name="Female" [[+fi.gender:is=`Female`:then=`selected="selected"`]]>Female</option>
            <option value="Male" id="Male" name="Male" [[+fi.gender:is=`Male`:then=`selected="selected"`]]>Male</option>
          </select>
          
        
          <span class="validationerror">[[!+fi.error.gender]]</span>
         </td>
        

        Some of them however are pretty long, for example date of birth is broken down into three drop downs, day, month and year, for year there are about 80 different selection options - don't know if there is a better way to be doing this?

        Thanks for your help
          • 8822
          • 203 Posts
          ah, that didn't appear to display correctly - whats the best way of inserting code into a reply?
            • 4172
            • 5,888 Posts
            you can try, if its faster by using a snippet like that:

            <?php
            //[[!makeOptions? &selectname=`gender` &options=`[{"value":"","caption":"Please Select"},{"value":"Male"},{"value":"Female"}]`]]
            
            $tpl = '<option value="[[+value]]" [[+selected]]>[[+caption]]</option>';
            $options = $modx->fromJson($options);
            $search = array('[[+value]]', '[[+caption]]', '[[+selected]]');
            $output = '';
            foreach ($options as $option) {
                $selected = $_REQUEST[$selectname] == $option['value'] ? 'selected="selected"' : '';
                $option['caption'] = isset($option['caption']) ? $option['caption'] : $option['value'];
                $replace = array($option['value'], $option['caption'], $selected);
                $output .= str_replace($search, $replace, $tpl);
            }
            
            return $output;
            


            and call it this way:

            <select name="gender" class="forminputs [[!+fi.error.gender:notempty=` error`]]" id="gender" tabindex="6" value="[[+fi.gender]]">
            [[!makeOptions? 
              &selectname=`gender` 
              &options=`[
                {"value":"","caption":"Please Select"},
                {"value":"Male"},
                {"value":"Female"}
              ]`
            ]]
            </select>
            
            
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 8822
              • 203 Posts
              HI Bruno,

              Thanks VERY much - i have tried your suggestion with one form and reduced the load time from 10 seconds to 3 seconds - a MUCH better response time. I have generally noticed that sites i have developed using MODX do take a second or two longer to load each page than ones i have developed without. Is this normal, or am i doing something wrong?

              Appreciate your help smiley