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_Controller » Bug #929

exportValues overwrite submitted arrays in multipage forms

Details

Submitted2004-03-01 14:05 UTC
Frombmansion at mamasam dot com
Assignedavb
StatusClosed
PackageHTML_QuickForm_Controller
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2004-03-01 14:05 UTC] bmansion at mamasam dot com

Description:
------------
If you have two pages, first one with $this->addElement('text', 'billing[tva]'...); and second with $this->addElement('text', 'billing[name]') upon processing, the first billing[tva] will be overwritten by the second billing element value, where it should be appended to the array.

Here is a fix to exportValues for review. The preg_match was changed to strpos btw, as it is supposedly faster.

function exportValues($pageName = null)
{
$data =& $this->container();
$values = array();
if (isset($pageName)) {
$pages = array($pageName);
} else {
$pages = array_keys($data['values']);
}
foreach ($pages as $page) {
// skip elements representing actions
foreach ($data['values'][$page] as $key => $value) {
if (strpos($key, '_qf_') !== 0) {
if (isset($values[$key])) {
$values[$key] = HTML_QuickForm::arrayMerge($values[$key], $value);
} else {
$values[$key] = $value;
}
}
}
}
return $values;
}