Home » HTML » HTML_QuickForm » Bug #5685
onQuickFormEvent handler not always called
Details
| Submitted | 2005-10-13 15:31 UTC |
|---|---|
| From | will_green at urscorp dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 5.0.4 |
| OS | Windows XP Pro |
| Roadmaps | (Not assigned) |
Comments
[2005-10-13 15:31 UTC] will_green at urscorp dot com
Description:
------------
Current stable version.
Elements created via the HTML_QuickForm::createElement() method, then subsequently added to an existing form via the $form->addElement($el) method DO NOT trigger the onQuickFormEvent() method with 'addElement' as the event.
What I am doing is creating a custom element that renders an FTP upload Java Applet in place of a file element. In order to make this work, I also add a hidden filed that will receive the file names of the uploaded files. For this to work, I need to add an onsubmit attribute to the containing form that will call a JavaScript function to get the file names and assign the string to the value of the hidden field. I am attempting to accomplish this with the onQuickFormEvent function.
If I create the element statically, then add it to the form, the onQuickFormEvent('addElement', $args, &$caller) method never gets called. This is NOT the expected behavior. onQuickFormEvent with 'addElement' as the event should be called weather the element was created statically or via the HTML_QuickForm::addElement() method.
Test script:
---------------
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Element.php';
class HTML_QuickForm_testelement extends HTML_QuickForm_Element {
function onQuickFormEvent($event, $arg, &$caller) {
echo '<hr>';
var_dump($event);
var_dump($arg);
var_dump($caller);
echo '<hr>';
}
}
HTML_QuickForm::registerElementType('testelement', __FILE__, 'HTML_QuickForm_testelement');
$form = new HTML_QuickForm('test');
// this does not work
$el =& HTML_QuickForm::createElement('testelement', 'testElement1', 'Created using HTML_QuickForm::createElement');
$form->addElement($el);
// this works as expected
$form->addElement('testelement', 'testElement2', 'Created using $form->addElement');
$form->display();
Expected result:
----------------
both 'createElement' and 'addElement' events should be triggered for $el.
Actual result:
--------------
only 'createElement' event is triggered for $el