Home » HTML » HTML_QuickForm » Bug #5206
Elements of the same name, in different forms, get mixed up
Details
| Submitted | 2005-08-25 10:03 UTC |
|---|---|
| From | zoe at monkeehouse dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.3.11 |
| OS | OS X |
| Roadmaps | (Not assigned) |
Comments
[2005-08-25 10:03 UTC] zoe at monkeehouse dot com
Description:
------------
I've made a form with a hidden element that has a value.
When the form is validated, a different form is created
with a hidden element of the same name. The value of the
original hidden element is used instead of the new
hidden element.
Test script:
---------------
require_once 'HTML/QuickForm.php';
$form_a = new HTML_QuickForm('form_a');
$form_a->addElement('hidden', 'same_name', 'this is form A');
$form_a->addElement('hidden', 'a_different_name', 'this is not broken because it has a different name');
$form_a->addElement('submit', 'submit', 'Submit');
if ($form_a->validate('form_a'))
{
$form_b = new HTML_QuickForm('form_b');
$form_b->addElement('hidden', 'same_name', 'this is form B');
$form_b->addElement('hidden', 'the_different_name', 'this is not broken because it has a different name');
$form_b->addElement('submit', 'submit', 'Submit');
$form_b->display();
}
else
{
$form_a->display();
}
Expected result:
----------------
Viewing the HTML source of the second form (after
submitting the first one) should reveal a hidden element
with a value of 'this is form B'.
Actual result:
--------------
The hidden element has a value of 'this is form A'.
[2005-08-25 11:49 UTC] bmansion at mamasam dot com
To set the elemnt values, it is recommended to use either setDefaults() or setConstants(). In your case, setConstants() should do.