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
some examples of your dropdowns?
ah, that didn't appear to display correctly - whats the best way of inserting code into a reply?
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>