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

Constructor ignores $attributes

Details

Submitted2006-09-17 13:32 UTC
Fromphp at ottolander dot nl
StatusBogus
PackageHTML_QuickForm
PHP VersionIrrelevant
OSn/r
Roadmaps(Not assigned)

Comments

[2006-09-17 13:32 UTC] php at ottolander dot nl

Description:
------------
The constructor ignores the $attributes field in contrast to what the function comment says.

You should either change the comment:

--- QuickForm.php.000 2006-09-15 23:52:06.000000000 +0200
+++ QuickForm.php 2006-09-16 06:10:06.000000000 +0200
@@ -249,7 +249,7 @@ class HTML_QuickForm extends HTML_Common
* @param string $method (optional)Form's method defaults to 'POST'
* @param string $action (optional)Form's action
* @param string $target (optional)Form's target defaults to '_self'
- * @param mixed $attributes (optional)Extra attributes for <form> tag
+ * @param mixed $attributes (unused)
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @access public
*/

or process the passed attributes:

--- QuickForm.php.000 2006-09-15 23:52:06.000000000 +0200
+++ QuickForm.php 2006-09-16 06:10:06.000000000 +0200
@@ -259,6 +259,7 @@ class HTML_QuickForm extends HTML_Common
$method = (strtoupper($method) == 'GET') ? 'get' : 'post';
$action = ($action == '') ? $_SERVER['PHP_SELF'] : $action;
$target = empty($target) ? array() : array('target' => $target);
+ $this->updateAttributes($attributes);
$attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$formName) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {

N.B. You might also want to improve the comment about $trackSubmit as follows:

- * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
+ * @param bool $trackSubmit (optional)Whether to track which form was submitted by adding a special hidden field

[2006-09-17 14:35 UTC] php at ottolander dot nl

You're right. I totally missed:
HTML_Common::HTML_Common($attributes);
The reuse of the variable name caused this oversight on my part.

s/if the/which/ in the comment regarding $trackSubmit seems a valid fix though.