PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #4219

_elementToArray in ArraySmary.php fails to check required / has error

Details

Submitted2005-04-25 10:50 UTC
Fromjoel at winstondesign dot se
AssignedThS
StatusClosed
PackageHTML_QuickForm
PHP Version4.3.9
OSMac OS X 10.3.9
Roadmaps(Not assigned)

Comments

[2005-04-25 10:50 UTC] joel at winstondesign dot se

Description:
------------
Using HTML_QuickForm 3.2.4pl1

In the _elementToArray() method in ArraySmarty.php the
check for if the element is required or has any errors
only checks if there is an template specified, not if
the element is requred / has errors. Resulting in slow
processing speed when the renderer is assinged to the
quickform object as the methods _renderRequired() and
_renderError() is used on every element.

By checking if we should apply _renderRequired() and
_renderError() we increase the speed of an average form
by more than 50%

Reproduce code:
---------------
Current code:
if (!empty($this->_required)){
$this->_renderRequired($ret['label'], $ret['html'], $required, $error);
}

if (!empty($this->_error)) {
$this->_renderError($ret['label'], $ret['html'], $error);
$ret['error'] = $error;
}

By checking if the element is required or if it has any errors we only run the code if necessary, increasing the scripts speed greatly.

if ($required && !empty($this->_required)){
$this->_renderRequired($ret['label'], $ret['html'], $required, $error);
}

if ($error && !empty($this->_error)) {
$this->_renderError($ret['label'], $ret['html'], $error);
$ret['error'] = $error;
}

[2006-01-12 00:26 UTC] justin at eckhouse dot com

I just upgraded and was somewhat disapointed to see this. I had this code which was meant to close a td whether there was an error or not:

$renderer->setErrorTemplate(
'{if $error}
class=\'ErrorCell\'>
<font color="red" size="1">{$error}</font><br />{$html}
{else}
>{$html}
{/if}
'
);

Is there a way to make this work with the existing version?