QF/QFC - odd behaviour?
| From: | Markus | Date: | Wed, 08 Oct 2003 00:10:54 +0000 |
| Subject: | QF/QFC - odd behaviour? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8332@lists.php.net to get a copy of this message | ||
I've had some problem with dynamically changing the contents of a QFC page.
Below is a complete example to show the problem. I hope you understand what
I mean if you look at it and test it. Just cut and paste. Is it a bug or
what am I doing wrong?
Thanks
/Markus
<?php
/**
* Example for showing odd beaviour in HTML_QuickForm_Controller: using
* $element->setValue() when there are any constats or defaults will
* have no effect.
*
* This migth be a result of the implementation of
* HTML_QuickForm_Element::onQuickFormEvent() ?!
*
*/
require_once 'HTML/QuickForm/Controller.php';
require_once 'HTML/QuickForm/Action.php';
// Start the session, form-page values will be kept there
session_start();
class SimplePage extends HTML_QuickForm_Page
{
function buildForm()
{
$this->_formBuilt = true;
$this->addElement('text', 'dummy', 'A dummy value:');
$text =& $this->addElement('textarea', 'tstText', 'Please
enter
something:');
$text->setRows(8);
$text->setCols(40);
$text->setValue("Last edit at:
".date('H:i:s')."\n".$text->getValue());
$this->addElement('submit', $this->getButtonName('add_edit_time'),
'Add edit time');
// *** Uncomment any of these will cause the form to misbehave! ***
// $this->setConstants(array('dummy' => 'A constant Value'));
// $this->setDefaults(array('dummy' => 'A default Value'));
}
}
class ModifyText extends HTML_QuickForm_Action
{
function perform(&$page, $actionName)
{
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('name');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
$data['valid'][$pageName] = $page->validate();
return $page->handle('display');
}
}
$page =& new SimplePage('page1');
$page->addAction('add_edit_time', new ModifyText());
$controller =& new HTML_QuickForm_Controller('simpleForm');
$controller->addPage($page);
$controller->run();
?>