quickform question
| From: | Andrea Bakker | Date: | Thu, 05 Nov 2009 11:57:29 +0000 |
| Subject: | quickform question | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30122@lists.php.net to get a copy of this message | ||
Hi
I have recently installed the pear quickform component. I am trying to learn it, but have come
across 2 problems.
1. When I hit submit (with valid data) , the screen goes blank - nothing displays
2. If I default to server side validation, when I hit submit, my screen comes up blank. No error
messages are displayed.
I couldn't find a "quickform" forum under the packages.
Below is my simple code :
require_once 'HTML/QuickForm.php';
// Instantiate the HTML_QuickForm object
$form = new HTML_QuickForm('firstForm');
// Set defaults for the form elements
$form->setDefaults(array(
'adname' => ''
));
// Add some elements to the form
$form->addElement('header', null, 'QuickForm tutorial example');
$form->addElement('text', 'adname', 'Enter your name:',
array('size' => 50, 'maxlength' => 255));
$form->addElement('select', 'categoryid', 'Choose a category:',
$categorylist);
$form->addElement('submit', null, 'Send');
// Define filters and validation rules
$form->applyFilter('adname', 'trim');
$form->addRule('adname', 'Please enter your name', 'required',
null, 'client');
//$form->addRule('adname', 'Please enter your name', 'required');
// Try to validate a form
if ($form->validate()) {
// Form is validated, then processes the data
//$form->freeze();
echo "the form is validated ";
$form->process('process_data', false);
}
else {
//$form->setDefaults($user);
$form->display();
}
function process_data ($values) {
echo "inside form process";
echo "<pre>";
foreach ($values as $key=>$value) {
echo $key."=".$value."<br>";
}
echo "</pre>";
}
?>
Any help would be appreciated
Thanks
Andrea