PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #6170

ITStatic: Form error block is always empty (w/ patch)

Details

Submitted2005-12-06 17:34 UTC
Fromrichter at jakota dot de
StatusBogus
PackageHTML_QuickForm
PHP Version4.3.2
OSDebian Linux
Roadmaps(Not assigned)

Comments

[2005-12-06 17:34 UTC] richter at jakota dot de

Description:
------------
I discovered the ITStaic renderer doesn't behave as explained in the docs with respect to a global form error block (at least when using the compatible Sigma templates).

Furthermore, the Tutorial states a wrong name scheme for the form error block.

Test script:
---------------
Snippet from my code:
$renderer = & new HTML_QuickForm_Renderer_ITStatic($formtpl);
$renderer->setErrorTemplate('');
$renderer->setRequiredTemplate('<span>{label}*</span>');
$form->accept($renderer);

An error template with no text should cause the renderer to fill error messages into the form error block which must be labeled following the scheme "formname_error_block", i.e.:
<!-- BEGIN formname_error_block -->
<font color="red">{formname_error}</font><br />
<!-- END formname_error_block -->

The tutorial says: "formname_error_loop" !

In ITStatic.php the line after the comment "Clean up after ourselves" has to be commented out for the global form error template to work:
function _renderError(&$label, &$html, $error)
{
if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_error_block')) {
$this->_tpl->setVariable($this->_formName . '_error', $error);
if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) {
$this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label);
if (is_array($label)) {
$label[0] = $this->_getTplBlock($tplBlock);
} else {
$label = $this->_getTplBlock($tplBlock);
}
} elseif (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) {
$this->_tpl->setVariable($this->_formName . '_html', $html);
$html = $this->_getTplBlock($tplBlock);
}
// clean up after ourselves
//$this->_tpl->setVariable($this->_formName . '_error', null);
} elseif (!empty($label) && strpos($this->_error, '{label}') !== false) {
if (is_array($label)) {
$label[0] = str_replace(array('{label}', '{error}'), array($label[0], $error), $this->_error);
} else {
$label = str_replace(array('{label}', '{error}'), array($label, $error), $this->_error);
}
} elseif (!empty($html) && strpos($this->_error, '{html}') !== false) {
$html = str_replace(array('{html}', '{error}'), array($html, $error), $this->_error);
} else {
$this->_errors[] = $error;
}
}// end func _renderError