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 #1994

Form tag not correctly created in Default Renderer

Details

Submitted2004-07-27 13:30 UTC
Fromchris dot read at gmail dot com
StatusBogus
PackageHTML_QuickForm
PHP Version5.0.0
OSIrelevant
Roadmaps(Not assigned)

Comments

[2004-07-27 13:30 UTC] chris dot read at gmail dot com

Description:
------------
The form tag created by Default renderer is not correctly created and you end up with a non-functioning form. May affect other renderers as well.

Attached a unified diff of Default.php that fixes the problem.

Reproduce code:
---------------
$form = new HTML_QuickForm('formtest', 'get');
$form->display();

---- Patch ----

--- Default.php 2004-06-15 11:40:15.000000000 +0100
+++ /usr/local/lib/php/HTML/QuickForm/Renderer/Default.php 2004-07-27 14:22:45.460960000 +0100
@@ -185,7 +185,14 @@
$this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_requiredNoteTemplate);
}
// add form attributes and content
- $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate);
+ $attr_string = '';
+ $attr_array = $form->getAttributes(true);
+ foreach (array_keys($attr_array) as $attr_key)
+ {
+ $attr_string .= ' ' . $attr_key . '="' . $attr_array[$attr_key] . '"';
+ }
+ $html = str_replace('{attributes}', $attr_string, $this->_formTemplate);
+
if (strpos($this->_formTemplate, '{hidden}')) {
$html = str_replace('{hidden}', $this->_hiddenHtml, $html);
} else {

Expected result:
----------------
<form action="/phones/formtest.php" method="get" name="formtest" id="formtest">
<div>

Actual result:
--------------
<formArray>
<div>

[2004-07-27 13:31 UTC] chris dot read at gmail dot com

Cleared up the summary to make more sense