QuickForm slowness with many checkboxes
| From: | Phil Gyford | Date: | Mon, 14 Mar 2005 16:03:07 +0000 |
| Subject: | QuickForm slowness with many checkboxes | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18023@lists.php.net to get a copy of this message | ||
Hi,
I'm using HTML_QuickForm and DB_DataObject quite happily with Smarty,
and all's mostly going well.
However, one form I'm working on has a checkbox set with around 250
checkboxes (yes, I know it's a lot). It works OK, but it does take
more than 20 seconds for QuickForm to "accept" the form! This is on a
server on my laptop, so a real server will be faster, but it does seem
excessive!
Is this to be expected? Without the checkbox set the call to
$form->accept() takes around 2 seconds (it has quite a lot of
elements). With the checkboxes, it takes at least 20. Have I done
anything obviously wrong in these bits of code that would make it so
slow...?
<start>
$source =& DB_DataObject::factory('Source');
$source->selectAdd();
$source->selectAdd('id, title');
$source->orderBy('title ASC');
$source->find();
$checkboxes = array();
// This adds around 250 checkboxes...
while ($source->fetch()) {
$checkname = 'source_'.$source->id;
$checkboxes[] = &HTML_QuickForm::createElement('checkbox',
$checkname, null, $source->title);
}
$form->addGroup($checkboxes, 'source_id', '', '<br />',
false);
<snip>
// $TEMPLATE is a Smarty template object.
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($TEMPLATE);
$form->accept($renderer);
<end>
Many thanks,
Phil