2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Import from DCARF SVN

This commit is contained in:
azammitdcarf
2008-10-15 22:36:05 +00:00
parent 4f0b4f0bbb
commit 1445da495b
2237 changed files with 714445 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
<?php
/**
* Example of usage for PEAR class HTML_QuickForm
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: elements.php,v 1.3 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
$form =& new HTML_QuickForm('frmTest', 'get');
// Use a two-label template for the elements that require some comments
$twoLabel = <<<_HTML
<tr valign="top">
<td align="right">
<!-- BEGIN required --><span style="color: #F00;">*</span><!-- END required --><b>{label}</b>
</td>
<td align="left">
<!-- BEGIN error --><span style="color: #F00;">{error}</span><br /><!-- END error -->{element}
<!-- BEGIN label_2 --><br /><span style="font-size: 80%;">{label_2}</span><!-- END label_2 -->
</td>
</tr>
_HTML;
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate($twoLabel, 'iadvChk');
$renderer->setElementTemplate($twoLabel, 'iautoComp');
// Fills with some defaults values
$form->setDefaults(array(
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'ichkTest' => true,
'iradTest' => 1,
'iselTest' => array('B', 'C'),
'name' => array('first'=>'Adam', 'last'=>'Daniel'),
'phoneNo' => array('513', '123', '3456'),
'iradYesNo' => 'Y',
'ichkABC' => array('A'=>true,'B'=>true),
'dateTest1' => array('d'=>11, 'm'=>1, 'Y'=>2003)
));
$form->setConstants(array(
'dateTest3' => time()
));
// Elements will be displayed in the order they are declared
$form->addElement('header', '', 'Normal Elements');
// Classic form elements
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'itxtTest', 'Test Text:');
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 3, 'cols' => 20));
$form->addElement('password', 'ipwdTest', 'Test Password:');
$form->addElement('checkbox', 'ichkTest', 'Test CheckBox:', 'Check the box');
$form->addElement('radio', 'iradTest', 'Test Radio Buttons:', 'Check the radio button #1', 1);
$form->addElement('radio', 'iradTest', '(Not a group)', 'Check the radio button #2', 2);
$form->addElement('button', 'ibtnTest', 'Test Button', array('onclick' => "alert('This is a test');"));
$form->addElement('reset', 'iresTest', 'Test Reset');
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('image', 'iimgTest', 'http://pear.php.net/gifs/pear-icon.gif');
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('header', '', 'Custom Elements');
// Date elements
$form->addElement('date', 'dateTest1', 'Date1:', array('format'=>'dmY', 'minYear'=>2010, 'maxYear'=>2001));
$form->addElement('date', 'dateTest2', 'Date2:', array('format'=>'d-F-Y H:i', 'language'=>'de', 'optionIncrement' => array('i' => 5)));
$form->addElement('date', 'dateTest3', 'Today is:', array('format'=>'l d M Y'));
$main[0] = "Pop";
$main[1] = "Rock";
$main[2] = "Classical";
$secondary[0][0] = "Belle & Sebastian";
$secondary[0][1] = "Elliot Smith";
$secondary[0][2] = "Beck";
$secondary[1][3] = "Noir Desir";
$secondary[1][4] = "Violent Femmes";
$secondary[2][5] = "Wagner";
$secondary[2][6] = "Mozart";
$secondary[2][7] = "Beethoven";
$opts[] = $main;
$opts[] = $secondary;
$hs =& $form->addElement('hierselect', 'ihsTest', 'Hierarchical select:', array('style' => 'width: 20em;'), '<br />');
$hs->setOptions($opts);
$form->addElement('advcheckbox', 'iadvChk', array('Advanced checkbox:', 'Unlike standard checkbox, this element <b>has</b> a value<br />when it is not checked.'), 'Check the box', null, array('off', 'on'));
$form->addElement('autocomplete', 'iautoComp', array('Your favourite fruit:', 'This is autocomplete element.<br />Start typing and see how it suggests possible completions.'), array('Pear', 'Orange', 'Apple'), array('size' => 30));
$form->addElement('header', '', 'Grouped Elements');
// Grouped elements
$name['last'] = &HTML_QuickForm::createElement('text', 'last', null, array('size' => 30));
$name['first'] = &HTML_QuickForm::createElement('text', 'first', null, array('size' => 20));
$form->addGroup($name, 'name', 'Name (last, first):', ',&nbsp;');
// Creates a group of text inputs
$areaCode = &HTML_QuickForm::createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 4));
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phoneNo', 'Telephone:', '-');
// Creates a radio buttons group
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
// Creates a checkboxes group
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$form->addGroup($checkbox, 'ichkABC', 'ABC:', '<br />');
// Creates a group of buttons to be displayed at the bottom of the form
$buttons[] = &HTML_QuickForm::createElement('submit', null, 'Submit');
$buttons[] = &HTML_QuickForm::createElement('reset', null, 'Reset');
$buttons[] = &HTML_QuickForm::createElement('image', 'iimgTest', 'http://pear.php.net/gifs/pear-icon.gif');
$buttons[] = &HTML_QuickForm::createElement('button', 'ibutTest', 'Test Button', array('onClick' => "alert('This is a test');"));
$form->addGroup($buttons, null, null, '&nbsp;', false);
// applies new filters to the element values
$form->applyFilter('__ALL__', 'trim');
// Adds some validation rules
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea must be at least 5 characters', 'minlength', 5);
$form->addRule('ipwdTest', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then processes the data
$form->freeze();
$form->process('myProcess', false);
echo "\n<HR>\n";
}
// Process callback
function myProcess($values)
{
echo '<pre>';
var_dump($values);
echo '</pre>';
}
$form->display();
?>

View File

@@ -0,0 +1,64 @@
<?php
/**
* Example of usage for PEAR class HTML_QuickForm.
* Using filters to clean up the submitted values.
*
* @category HTML
* @package HTML_QuickForm
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: filters.php,v 1.2 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
function _filterAustin($value)
{
return strtoupper($value).', GROOVY BABY!';
}
$form =& new HTML_QuickForm('frmTest', 'get');
$form->addElement('text', 'txtTest', 'Test Text to trim:');
$form->addRule('txtTest', 'Test text is required', 'required');
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 4, 'maxlength' => 4));
$form->addGroup($phoneGrp, 'phone', 'Telephone (will be converted to numbers):', '-');
$form->addGroupRule('phone', 'The phone is required', 'required', null, 3);
$form->addElement('text', 'txtAustin', 'Text for custom filter:');
$form->addRule('txtAustin', 'Custom filter text is required', 'required');
$form->addElement('submit', 'isubTest', 'Submit');
// now we apply the filters
$form->applyFilter('txtTest', 'trim');
// the filter will be applied recursively
$form->applyFilter('phone', 'intval');
if ($form->validate()) {
// Here the filter is applied after validation
$form->applyFilter('txtAustin', '_filterAustin');
echo "<pre>\n";
echo "Values before filter:\n\n";
var_dump($form->getElementValue('txtTest'));
echo "\n";
var_dump($form->getElementValue('phone'));
echo "\n";
var_dump($form->getElementValue('txtAustin'));
echo "\n\nValues after filter:\n\n";
var_dump($form->exportValue('txtTest'));
echo "\n";
var_dump($form->exportValue('phone'));
echo "\n";
var_dump($form->exportValue('txtAustin'));
echo "</pre>\n";
}
$form->display();
?>

View File

@@ -0,0 +1,104 @@
<?php
/**
* Examples of usage for HTML_QuickForm: fancy validation with addFormRule()
*
* $Id: formrule.php,v 1.2 2007/05/29 19:12:26 avb Exp $
*
* @category HTML
* @package HTML_QuickForm
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: formrule.php,v 1.2 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
function _validate_shipping($values)
{
// In Real Life (tm) you will probably query your DB for these
$profiles = array('foo', 'bar', 'baz');
$errors = array();
switch ($values['profile']) {
case 'personal':
if (empty($values['persProfileName'])) {
$errors['persProfileName'] = 'Enter the profile name';
} elseif (in_array($values['persProfileName'], $profiles)) {
$errors['persProfileName'] = 'The profile already exists';
}
if (empty($values['persName']['first']) || empty($values['persName']['last'])) {
$errors['persName'] = 'Name is required';
}
if (empty($values['persAddress'])) {
$errors['persAddress'] = 'Address is required';
}
break;
case 'company':
if (empty($values['compProfileName'])) {
$errors['compProfileName'] = 'Enter the profile name';
} elseif (in_array($values['compProfileName'], $profiles)) {
$errors['compProfileName'] = 'The profile already exists';
}
if (empty($values['compName'])) {
$errors['compName'] = 'Company name is required';
}
if (empty($values['compAddress'])) {
$errors['compAddress'] = 'Address is required';
}
break;
case 'existing':
default:
if (empty($values['profileName'])) {
$errors['profileName'] = 'Enter the profile name';
} elseif (!in_array($values['profileName'], $profiles)) {
$errors['profileName'] = 'The profile does not exist';
}
break;
} // switch
return empty($errors)? true: $errors;
}
$form =& new HTML_QuickForm('frmFancy');
$form->setDefaults(array(
'profile' => 'existing',
'stuffAmount' => '1'
));
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate("\n\t<tr>\n\t\t<td style=\"white-space: nowrap; background-color: #F0F0F0;\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{element}</b></td>\n\t</tr>", 'profile');
$form->addElement('header', null, 'Choose stuff');
$form->addElement('select', 'stuffName', 'Stuff to send:', array('' => '--select--', 'n' => 'Nuts', 'b' => 'Bolts', 'f' => 'Flotsam', 'j' => 'Jetsam'));
$form->addElement('text', 'stuffAmount', 'Amount of stuff:', array('size' => 2, 'maxlength' => 2));
$form->addElement('header', null, 'Choose shipping profile');
$form->addElement('static', 'note', 'Note:', 'profiles \'foo\', \'bar\' and \'baz\' are considered existing');
$form->addElement('radio', 'profile', null, 'Use existing profile', 'existing');
$form->addElement('text', 'profileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
$form->addElement('radio', 'profile', null, 'New personal profile', 'personal');
$form->addElement('text', 'persProfileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
$name[] =& $form->createElement('text', 'first', null, array('size' => 14, 'maxlength' => 100));
$name[] =& $form->createElement('text', 'last', null, array('size' => 14, 'maxlength' => 100));
$form->addGroup($name, 'persName', 'Name (first, last):', ' ');
$form->addElement('text', 'persAddress', 'Address:', array('size' => 32, 'maxlength' => 255));
$form->addElement('radio', 'profile', null, 'New company profile', 'company');
$form->addElement('text', 'compProfileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
$form->addElement('text', 'compName', 'Company name:', array('size' => 32, 'maxlength' => 100));
$form->addElement('text', 'compAddress', 'Address:', array('size' => 32, 'maxlength' => 255));
$form->addElement('submit', null, 'Send');
$form->addFormRule('_validate_shipping');
if ($form->validate()) {
echo "<pre>\n";
var_dump($form->exportValues());
echo "</pre>\n";
}
$form->display();
?>

View File

@@ -0,0 +1,96 @@
<?php
/**
* Examples of usage for grouped elements in HTML_QuickForm
*
* @category HTML
* @package HTML_QuickForm
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: groups.php,v 1.2 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
$form =& new HTML_QuickForm('frmGroups');
$form->setDefaults(array(
'id' => array('lastname' => 'Mamasam', 'code' => '1234'),
'phoneNo' => array('513', '123', '3456'),
'ichkABC' => array('A'=>true)
));
$renderer =& $form->defaultRenderer();
// Setting templates for form and headers
$renderer->setFormTemplate("<form{attributes}>\n<table width=\"450\" border=\"0\" cellpadding=\"3\" cellspacing=\"2\" bgcolor=\"#CCCC99\">\n{content}\n</table>\n</form>");
$renderer->setHeaderTemplate("\t<tr>\n\t\t<td style=\"white-space:nowrap;background:#996;color:#ffc;\" align=\"left\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>");
// Setting a special template for id element
$renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'id');
$renderer->setGroupElementTemplate('<td>{element}<br /><span style="font-size:10px;"><!-- BEGIN required --><span style="color: #f00">* </span><!-- END required --><span style="color:#996;">{label}</span></span></td>', 'id');
$form->addElement('header', '', 'Tests on grouped elements');
// Creates a group of text inputs with templates
$id['lastname'] = &HTML_QuickForm::createElement('text', 'lastname', 'Name', array('size' => 30));
$id['code'] = &HTML_QuickForm::createElement('text', 'code', 'Code', array('size' => 5, 'maxlength' => 4));
$form->addGroup($id, 'id', 'ID:', ',&nbsp');
// Add a complex rule for id element
$form->addGroupRule('id', array(
'lastname' => array(
array('Name is required', 'required', null, 'client'),
array('Name is letters only', 'lettersonly', null, 'client')
),
'code' => array(
array('Code must be numeric', 'numeric', null, 'client')
)
));
// Creates a group of text inputs
$areaCode = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 3));
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 3));
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, array('size' => 5, 'maxlength' => 4));
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phoneNo', 'Telephone:', '-');
// Adds validation rules for groups
$form->addGroupRule('phoneNo', 'Please fill all phone fields', 'required', null, 3, 'client');
$form->addGroupRule('phoneNo', 'Values must be numeric', 'numeric', null, 3, 'client');
// Creates a checkboxes group using an array of separators
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABC', 'ABCD:', array('&nbsp;', '<br />'));
// At least one element is required
$form->addGroupRule('ichkABC', 'Please check at least two boxes', 'required', null, 2, 'client', true);
// Creates a standard radio buttons group
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
// Validate the radio buttons
$form->addRule('iradYesNo', 'Check Yes or No', 'required', null, 'client');
// Creates a group of buttons to be displayed at the bottom of the form
$buttons[] =& $form->createElement('submit', null, 'Submit');
$buttons[] =& $form->createElement('reset', null, 'Reset');
$buttons[] =& $form->createElement('checkbox', 'clientSide', null, 'use client-side validation', array('checked' => 'checked', 'onclick' => "if (this.checked) {this.form.onsubmit = validate_" . $form->getAttribute('id') . ";} else {this.form.onsubmit = null;}"));
$form->addGroup($buttons);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then processes the data
$form->freeze();
$form->process('var_dump');
echo "\n<HR>\n";
}
$form->display();
?>

View File

@@ -0,0 +1,114 @@
<?php
/**
* Example of usage for HTML_QuickForm Object renderer
* with Flexy template engine and dynamic template
*
* @category HTML
* @package HTML_QuickForm
* @author Ron McClain <mixtli@cats.ucsc.edu>
* @version CVS: $Id: FlexyDynamic_example.php,v 1.3 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/Object.php';
require_once 'HTML/Template/Flexy.php';
$form = new HTML_QuickForm('frmTest', 'post');
$form->setDefaults(array(
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'iselTest' => array('B', 'C'),
'name' => array('first' => 'Thomas', 'last' => 'Schulz'),
'iradYesNo' => 'Y',
'ichkABCD' => array('A'=>true,'D'=>true)
));
$form->addElement('header', '', 'Normal Elements');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'itxtTest', 'Test Text');
$form->addElement('textarea', 'itxaTest', 'Test TextArea');
// will be later assigned to style green
$form->addElement('password', 'ipwdTest', array('Test Password', 'Please choose a password which is hard to guess'));
$select =& $form->addElement('select', 'iselTest', 'Test Select', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', '<br />');
// will be later assigned to style fancygroup
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
// will be later assigned to style fancygroup
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
// try to validate the form
if ($form->validate()) {
$form->freeze();
}
$renderer =& new HTML_QuickForm_Renderer_Object(true);
// give some elements aditional style informations
$renderer->setElementStyle(array(
'ipwdTest' => 'green',
'iradYesNo' => 'fancygroup',
'name' => 'fancygroup'
));
$form->accept($renderer);
$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
$options = array(
'templateDir' => './templates',
'compileDir' => './templates/build',
'debug' => 0
);
$tpl =& new HTML_Template_Flexy($options);
//$tpl->compile("styles/green.html");
//$tpl->compile("styles/fancygroup.html");
// assign array with form data
$view = new StdClass;
$view->form = $renderer->toObject();
// capture the array stucture
// (only for showing in sample template)
ob_start();
print_r($renderer->toObject());
$view->dynamic_object = ob_get_contents();
// XXX: dunno how to make Flexy ignore the placeholder
$view->formdata = '{formdata}';
ob_end_clean();
// render and display the template
$tpl->compile('flexy-dynamic.html');
$tpl->outputObject($view);
?>

View File

@@ -0,0 +1,150 @@
<?php
/**
* Example of usage for HTML_QuickForm Object renderer
* with Flexy template engine and static template
*
* @category HTML
* @package HTML_QuickForm
* @author Ron McClain <mixtli@cats.ucsc.edu>
* @version CVS: $Id: FlexyStatic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once('HTML/Template/Flexy.php');
require_once('HTML/QuickForm.php');
require_once('HTML/QuickForm/Renderer/ObjectFlexy.php');
function myProcess($values)
{
echo "<pre>";
var_dump($values);
echo "</pre>";
}
$form = new HTML_QuickForm('form', 'POST');
// Fills with some defaults values
$defaultValues['company'] = 'Devils son in law';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first'=>'Petey', 'last'=>'Wheatstraw');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
// Personal information
$form->addElement('header', 'personal', 'Personal Information');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', 'Your password:', 'size=10');
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First',
'size=10');
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last',
'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4
maxlength=3');
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4
maxlength=3');
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5
maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone',
'Telephone:', '-');
// Company information
$form->addElement('header', 'company_info', 'Company Information');
$form->addElement('text', 'company', 'Company:', 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$form->addGroup($str, 'street', 'Street:', '<br />');
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6
maxlength=10');
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City',
'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' =>
'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array('&nbsp;',
'<br />'));
// Other elements
$form->addElement('checkbox', 'news', '', " Check this box if you don't want
to receive our newsletter.");
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters',
'rangelength', array(8, 10),'client');
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes',
'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then freezes the data
$form->freeze();
$form->process('myProcess', false);
echo "\n<hr>\n";
}
// setup a template object
$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
$options = array(
'templateDir' => './templates',
'compileDir' => './templates/build',
'forceCompile' => 1,
'debug' => 0,
'local' => 'en'
);
$template = new HTML_Template_Flexy($options);
$renderer =& new HTML_QuickForm_Renderer_ObjectFlexy($template);
$renderer->setLabelTemplate("label.html");
$renderer->setHtmlTemplate("html.html");
$form->accept($renderer);
$view = new StdClass;
$view->form = $renderer->toObject();
$template->compile("flexy-static.html");
// capture the array stucture
ob_start();
print_r($view->form);
$view->static_object = ob_get_contents();
ob_end_clean();
// render and display the template
$template->outputObject($view);
?>

View File

@@ -0,0 +1,98 @@
<?php
/**
* Example of usage for HTML_QuickForm with ITDynamic renderer
*
* @category HTML
* @package HTML_QuickForm
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: ITDynamic_example.php,v 1.4 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
// can use either HTML_Template_Sigma or HTML_Template_ITX
require_once 'HTML/Template/ITX.php';
// require_once 'HTML/Template/Sigma.php';
$form = new HTML_QuickForm('frmTest', 'post');
$form->setDefaults(array(
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'iselTest' => array('B', 'C'),
'name' => array('first' => 'Alexey', 'last' => 'Borzov'),
'iradYesNo' => 'Y',
'ichkABCD' => array('A'=>true,'D'=>true)
));
$form->addElement('header', '', 'Normal Elements');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
// will be rendered in default qf_element block
$form->addElement('text', 'itxtTest', 'Test Text:');
// will be rendered in qf_textarea block, as it exists in template
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 5, 'cols' => 40));
// will be later assigned to qf_green, note that an array of labels is passed
$form->addElement('password', 'ipwdTest', array('Test Password:', 'The password is expected to be long enough.'));
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
// will be rendered in default qf_group block
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD:', array('&nbsp;', '<br />'));
// fancygroup candidates
// will be rendered in qf_fancygroup_radio
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
// will be rendered in qf_fancygroup_element
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
// try to validate the form
if ($form->validate()) {
$form->freeze();
}
// create a template object and load the template file
// can use either HTML_Template_Sigma or HTML_Template_ITX
$tpl =& new HTML_Template_ITX('./templates');
// $tpl =& new HTML_Template_Sigma('./templates');
$tpl->loadTemplateFile('it-dynamic.html', true, true);
// create a renderer
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
// assign elements to blocks
$renderer->setElementBlock(array(
'ipwdTest' => 'qf_green',
'iradYesNo' => 'qf_fancygroup',
'name' => 'qf_fancygroup'
));
// Black Magic :]
$form->accept($renderer);
// display the results
$tpl->show();
?>

View File

@@ -0,0 +1,122 @@
<?php
/**
* Example of usage for HTML_QuickForm with ITDynamic renderer (2-column layout)
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: ITDynamic_example2.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
// can use either HTML_Template_Sigma or HTML_Template_ITX
require_once 'HTML/Template/ITX.php';
//require_once 'HTML/Template/Sigma.php';
$form = new HTML_QuickForm('frmTest', 'POST');
// Fills with some defaults values
$defaultValues['company'] = 'Mamasam';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first'=>'Alexey', 'last'=>'Borzov');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
$form->addElement('hidden', 'timer', '12345');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
// Personal information
$form->addElement('header', 'personal_info', 'Personal Information');
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', 'Your password:', 'size=10');
// to finish the first column:
$form->addElement('static', null, null, 'first column');
// Company information
$form->addElement('header', 'company_info', 'Company Information');
$form->addElement('text', 'company', 'Company:', 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$form->addGroup($str, 'street', 'Street:', '<br />');
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
// Creates a checkboxes group using an array of separators
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array('&nbsp;', '<br />'));
// to finish the second column:
$form->addElement('static', null, null, 'second column');
// can't render these elements properly, so they are in the template
//$form->addElement('reset', 'reset', 'Reset');
//$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then freezes the data
$form->freeze();
}
// can use either HTML_Template_Sigma or HTML_Template_ITX
$tpl =& new HTML_Template_ITX('./templates');
// $tpl =& new HTML_Template_Sigma('./templates');
$tpl->loadTemplateFile('it-dynamic-2.html');
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
$renderer->setElementBlock(array(
'name' => 'qf_group_table',
'address' => 'qf_group_table'
));
$form->accept($renderer);
$tpl->show();
?>

View File

@@ -0,0 +1,114 @@
<?php
/**
* Example of usage for PEAR class HTML_QuickForm
*
* @category HTML
* @package HTML_QuickForm
* @author Bertrand Mansion <bmansion@mamasam.com>
* @version CVS: $Id: ITStatic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
// $Id: ITStatic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
require_once('HTML/QuickForm.php');
require_once('HTML/QuickForm/Renderer/ITStatic.php');
require_once('HTML/Template/ITX.php');
// Form name will be used to find the placeholders.
$form = new HTML_QuickForm('form', 'POST');
// Fills with some defaults values
$defaultValues['company'] = 'Mamasam';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first'=>'Bertrand', 'last'=>'Mansion');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
// Personal information
$form->addElement('header', 'personal', 'Personal Information');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', 'Your password:', 'size=10');
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
// Company information
$form->addElement('header', 'company_info', 'Company Information');
$form->addElement('text', 'company', 'Company:', 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$form->addGroup($str, 'street', 'Street:', '<br />');
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array('&nbsp;', '<br />'));
// Other elements
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then freezes the data
$form->freeze();
}
// Could be HTML_Template_Sigma('./templates')
$tpl =& new HTML_Template_ITX('./templates');
$tpl->loadTemplateFile('it-static.html');
$renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
$renderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>');
$renderer->setErrorTemplate('<font color="orange" size="1">{error}</font><br />{html}');
$form->accept($renderer);
$tpl->show();
?>

View File

@@ -0,0 +1,149 @@
<html>
<title>QuickForm Using QuickHtml Renderer</title>
<body>
<?php
/**
* Another example of usage for PEAR class HTML_QuickForm using the
* QuickHtml renderer.
*
* This renderer has three main distinctives: an easy way to create
* custom-looking forms, the ability to separate the creation of form
* elements from their display, and being able to use QuickForm in
* widget-based template systems. See the online documentation for more
* info.
*
* @category HTML
* @package HTML_QuickForm
* @author Jason Rust <jrust@rustyparts.com>
* @version CVS: $Id: QuickHtml_example.php,v 1.2 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once ("HTML/QuickForm.php");
require_once ("HTML/QuickForm/Renderer/QuickHtml.php");
$form =& new HTML_QuickForm('tmp_form','POST');
// get our render
$renderer =& new HTML_QuickForm_Renderer_QuickHtml();
// create the elements
createElements($form);
// set their values
setValues($form);
// Do the magic of creating the form. NOTE: order is important here: this must
// be called after creating the form elements, but before rendering them.
$form->accept($renderer);
// Because radio buttons have the same name we have to pass the value
// as well as the name in order to get the correct one.
$tmp_radio = ' Yes: ' . $renderer->elementToHtml('tmp_radio', 'Y');
$tmp_radio .= ' No: ' . $renderer->elementToHtml('tmp_radio', 'N');
$tmp_submit = $renderer->elementToHtml('tmp_reset');
$tmp_submit .= $renderer->elementToHtml('tmp_submit');
// Make our form table using some of the widget functions.
$data = '
<table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee" width="500">
<tr style="font-weight: bold;">' . createHeaderCell('QuickForm using QuickHtml Renderer', 'center', 2) . '</tr>
<tr>' . createFormCell($renderer->elementToHtml('tmp_textarea'), 'center', 2) . '</tr>
<tr>' . createHeaderCell('Text box (element is part of an array)', 'left') .
createHeaderCell('Yes or no?', 'right') . '</tr>
<tr>' . createFormCell($renderer->elementToHtml('tmp_text[array]'), 'left') .
createFormCell($tmp_radio, 'right') . '</tr>
<tr>' . createHeaderCell('Phone Number (a group)', 'left') .
createHeaderCell('Advanced Check Box?', 'right') . '</tr>
<tr>' . createFormCell($renderer->elementToHtml('phone_num'), 'left') .
createFormCell($renderer->elementToHtml('tmp_checkbox'), 'right') . '</tr>
<tr>' . createHeaderCell('Today is:', 'left') .
createHeaderCell('Multiple Select', 'right') . '</tr>
<tr>' . createFormCell($renderer->elementToHtml('tmp_date'), 'left') .
createFormCell($renderer->elementToHtml('tmp_multipleSelect[0]'), 'right') . '</tr>
<tr>' . createFormCell($tmp_submit, 'center', 2) . '</tr>
</table>';
// Wrap the form and any remaining elements (i.e. hidden elements) into the form tags.
echo $renderer->toHtml($data);
echo "\n<HR> <b>Submitted Values: </b><br />\n";
echo "<pre>";
print_r($_POST);
// {{{ createElements()
// creates all the fields for the form
function createElements(&$form)
{
// select list array
$selectListArray = array(
'windows' => 'Windows',
'linux' => 'Linux',
'irix' => 'Irix',
'mac' => 'Mac',
);
$form->addElement('text','tmp_text[array]',null,array('size' => 10));
$form->addElement('hidden','tmp_hidden', 'value');
$form->addElement('textarea','tmp_textarea',null,array('cols' => 50, 'rows' => 10, 'wrap' => 'virtual'));
$form->addElement('radio','tmp_radio',null,null,'Y');
$form->addElement('radio','tmp_radio',null,null,'N');
$text = array();
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3));
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 4));
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3));
$form->addGroup($text, 'phone_num', null, '-');
$form->addElement('advcheckbox','tmp_checkbox',null,'Please Check',null,array('not checked', 'checked'));
$form->addElement('date', 'tmp_date', null, array('format'=>'D d M Y'));
$form->addElement('select', 'tmp_multipleSelect[0]', null, $selectListArray, array('multiple' => 'multiple', 'size' => 4));
$form->addElement('reset','tmp_reset','Reset Form');
$form->addElement('submit','tmp_submit','Submit Form');
$form->addRule('tmp_text[array]','Text length must be greater than 10','minlength',10,'client');
}
// }}}
// {{{ setValues()
// sets all the default and constant values for the form
function setValues(&$form)
{
// Fills with some defaults values
$defaultValues['tmp_textarea'] = '
Test Text Area
With line breaks';
$defaultValues['phone_num'] = array('513', '123', '3456');
$defaultValues['tmp_checkbox'] = 'checked';
$defaultValues['tmp_multipleSelect'][0] = array('linux', 'mac');
// Fill with some constant values.
// Constant is not overridden by POST, GET, or defaultValues
// when values are being filled in
$constantValues['tmp_radio'] = 'Y';
$constantValues['tmp_date'] = time();
$constantValues['tmp_text']['array'] = 'constant';
$form->setDefaults($defaultValues);
$form->setConstants($constantValues);
}
// }}}
// {{{ createHeaderCell()
// creates a header cell
function createHeaderCell($text, $align, $colspan = 1)
{
return '<td align="' . $align . '" width="50%" bgcolor="#cccccc" colspan="' . $colspan . '">' . $text . '</td>';
}
// }}}
// {{{ createFormCell()
// creates a form cell based on the element name
function createFormCell($elementHtml, $align, $colspan = 1)
{
return '<td align="' . $align . '" width="50%" colspan="' . $colspan . '">' .
$elementHtml .
'</td>';
}
// }}}
?>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<?php
/**
* Example of usage for HTML_QuickForm Array renderer with Smarty template engine
*
* @category HTML
* @package HTML_QuickForm
* @author Thomas Schulz <ths@4bconsult.de>
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: SmartyDynamic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/Array.php';
// fix this if your Smarty is somewhere else
require_once 'Smarty.class.php';
$form = new HTML_QuickForm('frmTest', 'post');
$form->setDefaults(array(
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'iselTest' => array('B', 'C'),
'name' => array('first' => 'Thomas', 'last' => 'Schulz'),
'iradYesNo' => 'Y',
'ichkABCD' => array('A'=>true,'D'=>true)
));
$form->addElement('header', '', 'Normal Elements');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'itxtTest', array('Test Text', 'note' => 'Note for Testtext element.'));
$form->addElement('textarea', 'itxaTest', 'Test TextArea', 'cols="40" rows="2"');
// will be later assigned to style green
$form->addElement('password', 'ipwdTest', 'Test Password');
$select =& $form->addElement(
'select',
'iselTest',
array('Test Select', 'note' => 'We recommend to check at least two categories!'),
array('A'=>'A * * * * (luxory)', 'B'=>'B * * *','C'=>'C * *','D'=>'D * (simple)')
);
$select->setSize(4);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', array('&nbsp;', '<br />'));
// will be later assigned to style fancygroup
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
// will be later assigned to style fancygroup
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
// try to validate the form
if ($form->validate()) {
$form->freeze();
}
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
// give some elements aditional style informations
$renderer->setElementStyle(array(
'ipwdTest' => 'green',
'iradYesNo' => 'fancygroup',
'name' => 'fancygroup'
));
$form->accept($renderer);
// setup a template object
$tpl =& new Smarty;
$tpl->template_dir = './templates';
$tpl->compile_dir = './templates';
// assign array with form data
$tpl->assign('form', $renderer->toArray());
// capture the array stucture
// (only for showing in sample template)
ob_start();
print_r($renderer->toArray());
$tpl->assign('dynamic_array', ob_get_contents());
ob_end_clean();
// render and display the template
$tpl->display('smarty-dynamic.tpl');
?>

View File

@@ -0,0 +1,139 @@
<?php
/**
* Example of usage for HTML_QuickForm with Smarty renderer
*
* @category HTML
* @package HTML_QuickForm
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Thomas Schulz <ths@4bconsult.de>
* @version CVS: $Id: SmartyStatic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
// fix this if your Smarty is somewhere else
require_once 'Smarty.class.php';
// Form name will be used to find the placeholders.
$form = new HTML_QuickForm('form', 'POST');
// Fills with some defaults values
$defaultValues['company'] = 'Mamasam';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first'=>'Bertrand', 'last'=>'Mansion');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
// Personal information
$form->addElement('header', 'personal', 'Personal Information');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', array('Your password:', 'note'=>'Please, choose a 8-10 characters password.'), 'size=10');
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
// Company information
$form->addElement('header', 'company_info', 'Company Information');
$form->addElement('text', 'company', 'Company:', 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
$form->addGroup($str, 'street', 'Street:', '<br />');
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array('&nbsp;', '<br />'));
// Other elements
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then freezes the data
$form->freeze();
}
// setup a template object
$tpl =& new Smarty;
$tpl->template_dir = './templates';
$tpl->compile_dir = './templates';
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl, true);
$renderer->setRequiredTemplate(
'{if $error}
<font color="red">{$label|upper}</font>
{else}
{$label}
{if $required}
<font color="red" size="1">*</font>
{/if}
{/if}'
);
$renderer->setErrorTemplate(
'{if $error}
<font color="orange" size="1">{$error}</font><br />
{/if}{$html}'
);
$form->accept($renderer);
// assign array with form data
$tpl->assign('form', $renderer->toArray());
// capture the array stucture
ob_start();
print_r($renderer->toArray());
$tpl->assign('static_array', ob_get_contents());
ob_end_clean();
// render and display the template
$tpl->display('smarty-static.tpl');
?>

View File

@@ -0,0 +1,48 @@
<?php
/**
* Example of usage for QuickForm elements with multiple labels (using Default renderer)
*
* @category HTML
* @package HTML_QuickForm
* @author Jon Wood <jon@jellybob.co.uk>
* @version CVS: $Id: multiple-labels.php,v 1.2 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
$template =
'<tr>
<td align="right" valign="top">
<!-- BEGIN required --><font color="red">*</font><!-- END required -->
<b>{label}</b>
</td>
<td nowrap="nowrap" valign="top" align="left">
{element}
<!-- BEGIN error --><br/><font color="red">{error}</font><br/><!-- END error -->
<!-- BEGIN label_2 --><br/><font size="-1">{label_2}</font><!-- END label_2 -->
</td>
</tr>';
// Create the form, and add a header to it.
$form = new HTML_QuickForm('labels_example', 'post');
$form->addHeader('QuickForm Labels Example');
// Do the magic! Just pass your label to the element as an array!
$form->addElement('text', 'name', array('Name', 'The name that you would like to enter in this element.'));
$form->addElement('checkbox', 'check', array('Check Me!', 'If you check this box, it will have tick in it.'));
// More boring stuff.
$form->addElement('submit', null, 'Submit');
if ($form->validate()) {
$form->freeze();
}
// customize the element template
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate($template);
// output the form
$form->display();
?>

View File

@@ -0,0 +1,129 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- Id: flexy-dynamic.html,v 1.3 2003/05/21 13:27:59 avb Exp -->
<html>
<head>
<title>Flexy template for Object renderer</title>
<style type="text/css">
body, td, th {
font-family: sans-serif;
color: Navy;
background-color: #EEE;
font-size: smaller;
white-space: nowrap;
}
.maintable {
border: thin dashed #D0D0D0;
background-color: #EEE;
}
.header {
color: #FFF;
background-color: #999;
}
.green {
background-color : #CFC;
color: black;
}
.error {
color: red;
}
</style>
</head>
<body>
{form.javascript:h}
{form.outputHeader():h}
<table border="0" class="maintable" align="center">
{form.outputHeader():h}
{form.hidden:h}
{foreach:form.sections,sec}
<tr>
<td class="header" colspan="2">
<b>{sec.header}</b></td>
</tr>
{foreach:sec.elements,elem}
{if:elem.style}
{elem.outputStyle():h}
{else:}
{if:elem.isButton()}
{if:elem.notFrozen()}
<tr>
<td>&nbsp;</td>
<td align="left">{elem.html:h}</td>
</tr>
{end:}
{else:}
<tr>
{if:elem.isType(#textarea#)}
<td colspan="2">
{if:elem.required}<span class="error">*</span>{end:}
{if:elem.error}<span class="error">{end:}
<b>{elem.label:h}:</b><br />
{if:elem.error}</span>{end:}
{else:}
<td align="right" valign="top">
{if:elem.required}<span class="error">*</span>{end:}
{if:elem.error}<span class="error">{end:}
<b>{elem.label:h}:</b>
{if:elem.error}</span>{end:}
</td>
<td>
{end:}
{if:elem.error}<div class="error">{elem.error}</div>{end:}
{if:elem.isType(#group#)}
{foreach:elem.elements,gitem}
{gitem.label:h}
{gitem.html:h}{if:gitem.required}<span class="error">*</span>*</span>{end:}
{if:elem.separator}{elem.separator:h}{end:}
{end:}
{else:}
{elem.html:h}
{end:}
</td>
</tr>
{end:}
{end:}
{end:}
{end:}
{if:form.requirednote}
<tr>
<td>&nbsp;</td>
<td valign="top">{form.requirednote:h}</td>
</tr>
{end:}
</form>
</table>
&nbsp;
<p><b>Collected Errors:</b><br />
{foreach:form.errors,name,error}
<span class="error">{error:h}</span> in element [{name:h}]<br />
{end:}
</p>
&nbsp;
<p><strong>Best Practice: </strong><br />
Use only one dynamic form template like this for your <br />
Flexy driven project. You include this where <br />
to place a form with the formdata object rendered by <br />
Object QuickForm Renderer as option:</p>
<pre style="font-size: 12px;">
<strong>&lt;include file=form-dynamic.tpl form={formdata}&gt;</strong>
</pre>
&nbsp;
<p><strong>The used &quot;Dynamic&quot; Object </strong></p>
<pre style="font-size: 12px;">
{dynamic_object}
</pre>
</body>
</html>

View File

@@ -0,0 +1,154 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id: flexy-static.html,v 1.1 2003/08/05 09:34:48 mansion Exp $ -->
<html>
<head>
<title>Flexy template : 2 column layout example</title>
<style type="text/css">
.errors {
font-family: sans-serif;
color : #000;
background-color : #FFF;
font-size : 12pt;
}
.label {
font-family: sans-serif;
color : Navy;
font-size : 11px;
text-align : right;
vertical-align : top;
white-space: nowrap;
}
.element {
font-family: sans-serif;
background-color : #EEE;
text-align : left;
white-space: nowrap;
}
.note {
font-family: sans-serif;
background-color : #EEE;
text-align : center;
font-size : 10pt;
color : AAA;
white-space: nowrap;
}
th {
font-family: sans-serif;
font-size : small;
color : #FFF;
background-color : #AAA;
}
.maintable {
border : thin dashed #D0D0D0;
background-color : #EEE;
}
</style>
{form.javascript:h}
</head>
<body>
{form.outputHeader():h}
{form.hidden:h}
<table class="maintable" width="600" align="center">
<tr>
<td width="50%" valign="top"><!-- Personal info -->
<table width="100%" cellpadding="4">
<tr><th colspan="2">{form.header.personal:h}</th></tr>
<tr>
<td class="label">{form.name.label:h}</td>
<td class="element">{form.name.error:h}
<table cellspacing="0" cellpadding="1">
<tr>
<td>{form.name.first.html:h}</td>
<td>{form.name.last.html:h}</td>
</tr>
<tr>
<td><font size="1" color="grey">{form.name.first.label:h}</font></td>
<td><font size="1" color="grey">{form.name.last.label:h}</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="label">{form.phone.label:h}</td>
<td class="element">{form.phone.html:h}</td>
</tr>
<tr>
<td class="label">{form.email.label:h}</td>
<td class="element">{form.email.html:h}</td>
</tr>
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
<tr>
<td class="label">{form.pass.label:h}</td>
<td class="element">{form.pass.html:h}</td>
</tr>
</table>
</td>
<td width="50%" valign="top"><!-- Company info -->
<table width="100%" cellpadding="4">
<tr><th colspan="2">{form.header.company_info:h}</th></tr>
<tr>
<td class="label">{form.company.label:h}</td>
<td class="element">{form.company.html:h}</td>
</tr>
<tr>
<td class="label" valign="top">{form.street.label:h}</td>
<td class="element">{form.street.html:h}</td>
</tr>
<tr>
<td class="label">{form.address.label:h}</td>
<td class="element">{form.address.error:h}
<table cellspacing="0" cellpadding="1">
<tr>
<td>{form.address.zip.html:h}</td>
<td>{form.address.city.html:h}</td>
</tr>
<tr>
<td><font size="1" color="grey">{form.address.zip.label:h}</font></td>
<td><font size="1" color="grey">{form.address.city.label:h}</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="label">{form.country.label:h}</td>
<td class="element">{form.country.html:h}</td>
</tr>
<tr>
<td class="label">{form.destination.label:h}</td>
<td class="element">{form.destination.html:h}</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="600" align="center">
<tr>
<td>{form.requirednote:h}</td>
<td align="right">{form.reset.html:h}&nbsp;{form.submit.html:h}</td>
</tr>
<tr>
<td colspan="2" style="font-size:11px; color: navy;"><br />{form.news.html:h}</td>
</tr>
</table>
</form>
<br />
<b>Collected Errors:</b><br />
{foreach:form.errors,error}
<font color="red">{error}</font> in element [{name}]<br />
{end:}
&nbsp;
<p><strong>The used "Static" Object</strong></p>
<pre style="font-size: 12px;">
{static_object}
</pre>
</body>
</html>

View File

@@ -0,0 +1,4 @@
{if:error}
<font color="orange" size="1">{error:h}</font><br />
{end:}
{html:h}

View File

@@ -0,0 +1,110 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>IT dynamic renderer: 2 column layout example</title>
<style type="text/css">
.errors {
font-family: sans-serif;
color : #000;
background-color : #FFF;
font-size : 12pt;
}
.label {
font-family: sans-serif;
color : Navy;
background-color : #EEE;
font-size : 11px;
text-align : right;
vertical-align : top;
white-space: nowrap;
}
.element {
font-family: sans-serif;
background-color : #EEE;
text-align : left;
white-space: nowrap;
}
.note {
font-family: sans-serif;
background-color : #EEE;
text-align : center;
font-size : 10pt;
color : AAA;
white-space: nowrap;
}
th {
font-family: sans-serif;
font-size : small;
color : #FFC;
background-color : #AAA;
}
.maintable {
border : thin dashed #D0D0D0;
background-color : #EEE;
}
</style>
{qf_javascript}
</head>
<body>
<!-- BEGIN qf_error_loop -->
<font color="red">{qf_error}</font><br />
<!-- END qf_error_loop -->
<form {qf_attributes}>
<!-- BEGIN qf_hidden_block -->
<div style="display: none;">
<!-- BEGIN qf_hidden_loop -->
{qf_hidden}
<!-- END qf_hidden_loop -->
</div>
<!-- END qf_hidden_block -->
<table class="maintable" width="600" align="center">
<tr>
<!-- BEGIN qf_main_loop -->
<!-- BEGIN qf_header -->
<td width="50%" valign="top">
<table width="100%" cellpadding="4">
<tr><th colspan="2">{qf_header}</th></tr>
<!-- END qf_header -->
<!-- BEGIN qf_element -->
<tr><td class="label"><!-- BEGIN qf_element_required --><span style="color: #FF0000;">*</span> <!-- END qf_element_required -->{qf_label}</td><td class="element"><!-- BEGIN qf_element_error --><font size="1" color="red">{qf_error}</font><br /><!-- END qf_element_error -->{qf_element}</td></tr>
<!-- END qf_element -->
<!-- BEGIN qf_password -->
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
<tr><td class="label"><!-- BEGIN qf_password_required --><span style="color: #FF0000;">*</span> <!-- END qf_password_required --><span style="color: green;">{qf_label}</span></td><td class="element"><!-- BEGIN qf_password_error --><font size="1" color="red">{qf_error}</font><br /><!-- END qf_password_error -->{qf_element}</td></tr>
<!-- END qf_password -->
<!-- BEGIN qf_group -->
<tr>
<td class="label"><!-- BEGIN qf_group_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_required -->{qf_group_label}</td>
<td class="element"><!-- BEGIN qf_group_loop --><!-- BEGIN qf_group_element -->{qf_separator}{qf_element}<!-- END qf_group_element --><!-- END qf_group_loop --></td>
</tr>
<!-- END qf_group -->
<!-- BEGIN qf_group_table -->
<tr>
<td class="label"><!-- BEGIN qf_group_table_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_table_required -->{qf_group_label}</td>
<td class="element"><table cellpadding="0" cellspacing="0"><tr>
<!-- BEGIN qf_group_table_loop --><!-- BEGIN qf_group_table_element -->
<td>{qf_element}<br /><span style="font-size: 80%; color: #999;">{qf_label}<!-- BEGIN qf_group_table_element_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_table_element_required --></span></td>
<!-- END qf_group_table_element --><!-- END qf_group_table_loop -->
</tr></table></td>
</tr>
<!-- END qf_group_table -->
<!-- BEGIN qf_static -->
</table>
</td><!-- {qf_element} ends -->
<!-- END qf_static -->
<!-- END qf_main_loop -->
</tr>
</table>
<table width="600" align="center">
<tr>
<td>{qf_required_note}</td>
<td align="right"><input name="reset" value="Reset" type="reset" />&nbsp;<input name="submit" value="Register" type="submit" /></td>
</tr>
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,127 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>IT dynamic renderer</title>
<style type="text/css">
body, td, th {
font-family: sans-serif;
color : Navy;
background-color : #EEE;
font-size : smaller;
white-space: nowrap;
}
.maintable {
border : thin dashed #D0D0D0;
background-color : #EEE;
}
.header {
color : #FFF;
background-color : #AAA;
}
.green {
background-color : #CFC;
color : black;
}
</style>
</head>
<body>
{qf_javascript}
<form {qf_attributes}>
<!-- BEGIN qf_hidden_block -->
<div style="display: none;">
<!-- BEGIN qf_hidden_loop -->
{qf_hidden}
<!-- END qf_hidden_loop -->
</div>
<!-- END qf_hidden_block -->
<table border="0" class="maintable" align="center">
<!-- BEGIN qf_errors -->
<tr>
<td align="left" valign="top" colspan="2">
<ul>
<!-- BEGIN qf_error_loop -->
<li>{qf_error}</li>
<!-- END qf_error_loop -->
</ul>
</td>
</tr>
<!-- END qf_errors -->
<!-- BEGIN qf_main_loop -->
<!-- BEGIN qf_header -->
<tr>
<td align="left" valign="top" colspan="2" class="header"><b>{qf_header}</b></td>
</tr>
<!-- END qf_header -->
<!-- BEGIN qf_element -->
<tr>
<td align="right" valign="top"><!-- BEGIN qf_element_required --><span style="color: #FF0000;">*</span><!-- END qf_element_required --><b>{qf_label}</b></td>
<td valign="top" align="left"><!-- BEGIN qf_element_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_element_error -->{qf_element}</td>
</tr>
<!-- END qf_element -->
<!-- BEGIN qf_textarea -->
<tr>
<td valign="top" colspan="2"><!-- BEGIN qf_textarea_required --><span style="color: #FF0000;">*</span><!-- END qf_textarea_required --><b>{qf_label}</b><br />
<!-- BEGIN qf_textarea_error --><span style="color: #FF0000;">{qf_error}</span><br><!-- END qf_textarea_error -->{qf_element}</td>
</tr>
<!-- END qf_textarea -->
<!-- BEGIN qf_group -->
<tr>
<td align="right" valign="top"><!-- BEGIN qf_group_required --><span style="color: #FF0000;">*</span><!-- END qf_group_required --><b>{qf_group_label}</b></td>
<td valign="top" align="left">
<!-- BEGIN qf_group_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_group_error -->
<!-- BEGIN qf_group_loop --><!-- BEGIN qf_group_element -->{qf_separator}{qf_element}<!-- END qf_group_element --><!-- END qf_group_loop -->
</td>
</tr>
<!-- END qf_group -->
<!-- BEGIN qf_fancygroup -->
<tr>
<td align="right" valign="top"><span<!-- BEGIN qf_fancygroup_required --> style="font-weight: bold; color: red"<!-- END qf_fancygroup_required -->>{qf_group_label}</span></td>
<td valign="top" align="left">
<table cellspacing="2">
<!-- BEGIN qf_fancygroup_loop -->
<tr>
<!-- BEGIN qf_fancygroup_element -->
<td class="green" align="right"><!-- BEGIN qf_fancygroup_element_required --><span style="color: #FF0000;">*</span><!-- END qf_fancygroup_element_required -->{qf_label}</td>
<td class="green">{qf_element}</td>
<!-- END qf_fancygroup_element -->
<!-- BEGIN qf_fancygroup_radio -->
<td colspan="2" class="green">{qf_element}</td>
<!-- END qf_fancygroup_radio -->
</tr>
<!-- END qf_fancygroup_loop -->
</table>
</td>
</tr>
<!-- END qf_fancygroup -->
<!-- BEGIN qf_green -->
<tr>
<td align="right" valign="top" class="green"><!-- BEGIN qf_green_required --><span style="color: #FF0000;">*</span><!-- END qf_green_required --><b>{qf_label}</b></td>
<td valign="top" align="left" class="green"><!-- BEGIN qf_green_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_green_error -->{qf_element}
<!-- BEGIN qf_green_label_2 --><br /><span style="font-size: 80%;">{qf_label_2}</span><!-- END qf_green_label_2 --></td>
</tr>
<!-- END qf_green -->
{qf_addblock}
<!-- END qf_main_loop -->
<!-- BEGIN qf_required_note -->
<tr>
<td>&nbsp;</td>
<td align="left" valign="top">{qf_required_note}</td>
</tr>
<!-- END qf_required_note -->
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,102 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>IT static render: 2 column layout example</title>
<style type="text/css">
.errors {
font-family: sans-serif;
color : #000;
background-color : #FFF;
font-size : 12pt;
}
.label {
font-family: sans-serif;
color : Navy;
font-size : 11px;
text-align : right;
vertical-align : top;
white-space: nowrap;
}
.element {
font-family: sans-serif;
background-color : #EEE;
text-align : left;
white-space: nowrap;
}
.note {
font-family: sans-serif;
background-color : #EEE;
text-align : center;
font-size : 10pt;
color : AAA;
white-space: nowrap;
}
th {
font-family: sans-serif;
font-size : small;
color : #FFF;
background-color : #AAA;
}
.maintable {
border : thin dashed #D0D0D0;
background-color : #EEE;
}
</style>
{form_javascript}
</head>
<body>
<!-- BEGIN form_error_loop -->
<font color="red">{form_error}</font><br /><!-- END form_error_loop -->
<form {form_attributes}>
{form_session_html}
<table class="maintable" width="600" align="center">
<tr><td width="50%" valign="top"><!-- Personal info -->
<table width="100%" cellpadding="4"><tr><th colspan="2">{form_header_personal}</th></tr>
<tr>
<td class="label">{form_name_label}</td>
<td class="element"><!-- BEGIN form_name_error -->{form_name_error}<!-- END form_name_error -->
<table cellspacing="0" cellpadding="1">
<tr><td>{form_name_first_html}</td><td>{form_name_last_html}</td></tr>
<tr><td><font size="1" color="grey">{form_name_first_label}</font></td><td><font size="1" color="grey">{form_name_last_label}</font></td></tr>
</table>
</td>
</tr>
<tr><td class="label">{form_phone_label}</td><td class="element">{form_phone_html}</td></tr>
<tr><td class="label">{form_email_label}</td><td class="element">{form_email_html}</td></tr>
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
<tr><td class="label">{form_pass_label}</td><td class="element">{form_pass_html}</td></tr>
</table>
</td><td width="50%" valign="top"><!-- Company info -->
<table width="100%" cellpadding="4"><tr><th colspan="2">{form_header_company_info}</th></tr>
<tr><td class="label">{form_company_label}</td><td class="element">{form_company_html}</td></tr>
<tr><td class="label" valign="top">{form_street_label}</td><td class="element">{form_street_html}</td></tr>
<tr>
<td class="label">{form_address_label}</td>
<td class="element"><!-- BEGIN form_address_error -->{form_address_error}<!-- END form_address_error -->
<table cellspacing="0" cellpadding="1">
<tr><td>{form_address_zip_html}</td><td>{form_address_city_html}</td></tr>
<tr><td><font size="1" color="grey">{form_address_zip_label}</font></td><td><font size="1" color="grey">{form_address_city_label}</font></td></tr>
</table>
</td>
</tr>
<tr><td class="label">{form_country_label}</td><td class="element">{form_country_html}</td></tr>
<tr><td class="label">{form_destination_label}</td><td class="element">{form_destination_html}</td></tr>
</table>
</td>
</tr>
</table>
<table width="600" align="center">
<tr>
<td>{form_required_note}</td>
<td align="right">{form_reset_html}&nbsp;{form_submit_html}</td>
</tr>
<tr>
<td colspan="2" style="font-size:11px; color: navy;"><br />{form_news_html}</td>
</tr>
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,4 @@
{if:required}
<font color="red" size="1">*</font>
{end:}
{label:h}

View File

@@ -0,0 +1,28 @@
<!-- $Id: smarty-dynamic-fancygroup.tpl,v 1.1 2003/04/30 19:23:35 avb Exp $ -->
<tr>
<td valign="top" align="right">
<b{if $element.error} style="color: Red;"{/if}>{if $element.required}<font color="red">*</font>{/if}{$element.label}:</b>
</td>
<td>
<table cellspacing="2" border="0">
{foreach key=gkey item=gitem from=$element.elements}
<tr>
{if $gitem.type eq "radio"}
<td colspan="2" class="green">
{$gitem.html}
</td>
{else}
<td class="green" align="right">
{if $gitem.required}<font color="red">*</font>{/if}
{$gitem.label}
</td>
<td class="green">
{$gitem.html}
</td>
{/if}
</tr>
{/foreach}
</table>
</td>
</tr>

View File

@@ -0,0 +1,9 @@
<!-- $Id: smarty-dynamic-green.tpl,v 1.1 2003/04/30 19:23:35 avb Exp $ -->
<tr>
<td align="right" valign="top" class="green"><b>{$element.label}:</b></td>
<td valign="top" align="left" class="green">
{if $element.error}<font color="red">{$element.error}</font><br />{/if}
{$element.html}{if $element.required}<font color="red">*</font>{/if}
</td>
</tr>

View File

@@ -0,0 +1,134 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id: smarty-dynamic.tpl,v 1.5 2004/08/10 10:06:42 ths Exp $ -->
<html>
<head>
<title>Smarty template for Array renderer</title>
<style type="text/css">
{literal}
body, td, th {
font-family: sans-serif;
color: Navy;
background-color : #EEE;
font-size: smaller;
white-space: nowrap;
}
.maintable {
border: thin dashed #D0D0D0;
background-color: #EEE;
}
.header {
color: #FFF;
background-color: #999;
}
.green {
background-color: #CFC;
color: black;
}
{/literal}
</style>
</head>
<body>
{$form.javascript}
<table border="0" class="maintable" align="center">
<form{$form.attributes}>{$form.hidden}
{foreach item=sec key=i from=$form.sections}
<tr>
<td class="header" colspan="2">
<b>{$sec.header}</b></td>
</tr>
{foreach item=element from=$sec.elements}
<!-- elements with alternative layout in external template file-->
{if $element.style}
{include file="smarty-dynamic-`$element.style`.tpl}
{*
NOTE: Another way ist to have smarty template code in
$element.style. In this case you can do:
{if $element.style}
{eval var=$element.style}
*}
<!-- submit or reset button (don't display on frozen forms) -->
{elseif $element.type eq "submit" or $element.type eq "reset"}
{if not $form.frozen}
<tr>
<td>&nbsp;</td>
<td align="left">{$element.html}</td>
</tr>
{/if}
<!-- normal elements -->
{else}
<tr>
{if $element.type eq "textarea"}
<td colspan="2">
{if $element.required}<font color="red">*</font>{/if}<b>{$element.label}</b><br />
{else}
<td align="right" valign="top">
{if $element.required}<font color="red">*</font>{/if}<b>{$element.label}:</b></td>
<td>
{/if}
{if $element.error}<font color="red">{$element.error}</font><br />{/if}
{if $element.type eq "group"}
{foreach key=gkey item=gitem from=$element.elements}
{$gitem.label}
{$gitem.html}{if $gitem.required}<font color="red">*</font>{/if}
{if $element.separator}{cycle values=$element.separator}{/if}
{/foreach}
{else}
{$element.html}
{/if}
<div style="font-size: 80%;">{$element.label_note}</div>
</td>
</tr>
{/if}
{/foreach}
{/foreach}
{if $form.requirednote and not $form.frozen}
<tr>
<td>&nbsp;</td>
<td valign="top">{$form.requirednote}</td>
</tr>
{/if}
</form>
</table>
&nbsp;
<p><b>Collected Errors:</b><br />
{foreach key=name item=error from=$form.errors}
<font color="red">{$error}</font> in element [{$name}]<br />
{/foreach}
</p>
&nbsp;
<p><strong>Best Practice: </strong><br />
Use only one dynamic form template like this for your <br />
Smarty driven project. You include this where <br />
to place a form with the formdata-Array rendered by <br />
SmartyDynamic QuickForm Renderer as option:</p>
<pre style="font-size: 12px;">
<strong>{ldelim}include file=form-dynamic.tpl form=$formdata{rdelim}</strong>
</pre>
&nbsp;
<p><strong>The used "Dynamic" Array </strong></p>
<pre style="font-size: 12px;">
{$dynamic_array|htmlentities}
</pre>
</body>
</html>

View File

@@ -0,0 +1,156 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- $Id: smarty-static.tpl,v 1.3 2004/10/15 20:30:56 ths Exp $ -->
<html>
<head>
<title>Smarty template for ArraySmarty renderer: 2 column layout example</title>
<style type="text/css">
{literal}
.errors {
font-family: sans-serif;
color : #000;
background-color : #FFF;
font-size : 12pt;
}
.label {
font-family: sans-serif;
color : Navy;
font-size : 11px;
text-align : right;
vertical-align : top;
white-space: nowrap;
}
.element {
font-family: sans-serif;
background-color : #EEE;
text-align : left;
white-space: nowrap;
}
.note {
font-family: sans-serif;
background-color : #EEE;
text-align : center;
font-size : 10pt;
color : AAA;
white-space: nowrap;
}
th {
font-family: sans-serif;
font-size : small;
color : #FFF;
background-color : #AAA;
}
.maintable {
border : thin dashed #D0D0D0;
background-color : #EEE;
}
{/literal}
</style>
{$form.javascript}
</head>
<body>
<form {$form.attributes}>
{$form.hidden}
<table class="maintable" width="600" align="center">
<tr>
<td width="50%" valign="top"><!-- Personal info -->
<table width="100%" cellpadding="4">
<tr><th colspan="2">{$form.header.personal}</th></tr>
<tr>
<td class="label">{$form.name.label}</td>
<td class="element">{$form.name.error}
<table cellspacing="0" cellpadding="1">
<tr>
<td>{$form.name.first.html}</td>
<td>{$form.name.last.html}</td>
</tr>
<tr>
<td><font size="1" color="grey">{$form.name.first.label}</font></td>
<td><font size="1" color="grey">{$form.name.last.label}</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="label">{$form.phone.label}</td>
<td class="element">{$form.phone.html}</td>
</tr>
<tr>
<td class="label">{$form.email.label}</td>
<td class="element">{$form.email.html}</td>
</tr>
<tr><td colspan="2" class="note">{$form.pass.label_note}</td></tr>
<tr>
<td class="label">{$form.pass.label}</td>
<td class="element">{$form.pass.html}</td>
</tr>
</table>
</td>
<td width="50%" valign="top"><!-- Company info -->
<table width="100%" cellpadding="4">
<tr><th colspan="2">{$form.header.company_info}</th></tr>
<tr>
<td class="label">{$form.company.label}</td>
<td class="element">{$form.company.html}</td>
</tr>
<tr>
<td class="label" valign="top">{$form.street.label}</td>
<td class="element">{$form.street.html}</td>
</tr>
<tr>
<td class="label">{$form.address.label}</td>
<td class="element">{$form.address.error}
<table cellspacing="0" cellpadding="1">
<tr>
<td>{$form.address.zip.html}</td>
<td>{$form.address.city.html}</td>
</tr>
<tr>
<td><font size="1" color="grey">{$form.address.zip.label}</font></td>
<td><font size="1" color="grey">{$form.address.city.label}</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="label">{$form.country.label}</td>
<td class="element">{$form.country.html}</td>
</tr>
<tr>
<td class="label">{$form.destination.label}</td>
<td class="element">{$form.destination.html}</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="600" align="center">
<tr>
<td>{$form.requirednote}</td>
<td align="right">{$form.reset.html}&nbsp;{$form.submit.html}</td>
</tr>
<tr>
<td colspan="2" style="font-size:11px; color: navy;"><br />{$form.news.html}</td>
</tr>
</table>
</form>
<br />
<b>Collected Errors:</b><br />
{foreach key=name item=error from=$form.errors}
<font color="red">{$error}</font> in element [{$name}]<br />
{/foreach}
&nbsp;
<p><strong>The used "Static" Array</strong></p>
<pre style="font-size: 12px;">
{$static_array|htmlentities}
</pre>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<tr>
<td valign="top" align="right">
{if:required}<span class="error">*</span>{end:}
{if:error}<span class="error">{end:}
<b>{label:h}:</b>
{if:error}</span>{end:}
</td>
<td>
{if:error}<div class="error">{error}</div>{end:}
<table cellspacing="2" border="0">
{foreach:elements,gitem}
<tr>
{if:gitem.isType(#radio#)}
<td colspan="2" class="green">
{gitem.html:h}
</td>
{else:}
<td class="green" align="right">
{if:gitem.required}<span class="error">*</span>{end:}
{gitem.label:h}
</td>
<td class="green">
{gitem.html:h}
</td>
{end:}
</tr>
{end:}
</table>
</td>
</tr>

View File

@@ -0,0 +1,10 @@
<!-- $Id: green.html,v 1.2 2003/11/03 12:55:52 avb Exp $ -->
<tr>
<td align="right" valign="top" class="green">{if:required}<font color="red">*</font>{end:}<b>{label:h}:</b></td>
<td valign="top" align="left" class="green">
{if:error}<font color="red">{error:h}</font><br />{end:}
{html:h}
{if:label_2}<br /><span style="font-size: 75%">{label_2:h}</span>{end:}
</td>
</tr>

View File

@@ -0,0 +1,89 @@
<?php
/**
* Usage example for HTML_QuickForm, built-in validation rules.
*
* @category HTML
* @package HTML_QuickForm
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: rules-builtin.php,v 1.5 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
$form =& new HTML_QuickForm('builtin');
// We need an additional label below the element
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate(<<<EOT
<tr>
<td align="right" valign="top" nowrap="nowrap"><!-- BEGIN required --><span style="color: #ff0000">*</span><!-- END required --><b>{label}</b></td>
<td valign="top" align="left">
<!-- BEGIN error --><span style="color: #ff0000">{error}</span><br /><!-- END error -->{element}
<!-- BEGIN label_2 --><br/><span style="font-size: 80%">{label_2}</span><!-- END label_2 -->
</td>
</tr>
EOT
);
$form->addElement('header', null, 'Required rule');
$form->addElement('text', 'rRequired', array('Required:', 'Rule type \'required\'<br />Note: when the field is not \'required\' and is empty, other validation rules will <b>not</b> be applied to it'));
$form->addRule('rRequired', 'The field is required', 'required', null, 'client');
// RangeLength rules
$form->addElement('header', null, 'Range based rules');
$form->addElement('text', 'rMaxLength', array('Maximum length check (5):', 'Rule type \'maxlength\', $format = 5'));
$form->addElement('text', 'rMinLength', array('Minimum length check (5):', 'Rule type \'minlength\', $format = 5'));
$form->addElement('text', 'rRangeLength', array('Length range check (5-10):', 'Rule type \'rangelength\', $format = array(5, 10)'));
$form->addRule('rMaxLength', 'Should be less than or equal to 5 symbols', 'maxlength', 5, 'client');
$form->addRule('rMinLength', 'Should be more than or equal to 5 symbols', 'minlength', 5, 'client');
$form->addRule('rRangeLength', 'Should be between 5 and 10 symbols', 'rangelength', array(5,10), 'client');
// Email rule
$form->addElement('header', null, 'Email rule');
$form->addElement('text', 'rEmail', array('Email check:', 'Rule type \'email\''));
$form->addRule('rEmail', 'Should contain a valid email', 'email', null, 'client');
// RegEx rules
$form->addElement('header', null, 'Regex based rules');
$form->addElement('text', 'rRegex', array('Letters \'A\', \'B\', \'C\' only:', 'Rule type \'regex\' with $format = \'/^[ABCabc]+$/\''));
$form->addElement('text', 'rLettersOnly', array('Letters only:', 'Rule type \'lettersonly\''));
$form->addElement('text', 'rAlphaNumeric', array('Alphanumeric:', 'Rule type \'alphanumeric\''));
$form->addElement('text', 'rNumeric', array('Numeric:', 'Rule type \'numeric\''));
$form->addElement('text', 'rNoPunctuation', array('No punctuation:', 'Rule type \'nopunctuation\''));
$form->addElement('text', 'rNonZero', array('Nonzero:', 'Rule type \'nonzero\''));
$form->addRule('rRegex', 'Should contain letters A, B, C only', 'regex', '/^[ABCabc]+$/', 'client');
$form->addRule('rLettersOnly', 'Should contain letters only', 'lettersonly', null, 'client');
$form->addRule('rAlphaNumeric', 'Should be alphanumeric', 'alphanumeric', null, 'client');
$form->addRule('rNumeric', 'Should be numeric', 'numeric', null, 'client');
$form->addRule('rNoPunctuation', 'Should contain no punctuation', 'nopunctuation', null, 'client');
$form->addRule('rNonZero', 'Should be nonzero', 'nonzero', null, 'client');
// Compare rule
$form->addElement('header', null, 'Compare rule');
$form->addElement('password', 'cmpPasswd', 'Password:');
$form->addElement('password', 'cmpRepeat', array('Repeat password:', 'Rule type \'compare\', added to array(\'cmpPasswd\', \'cmpRepeat\')'));
$form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not match', 'compare', null, 'client');
// File rules
$form->addElement('header', null, 'Uploaded file rules');
$form->addElement('file', 'tstUpload', array('Upload file:', 'Rule types: \'uploadedfile\', \'maxfilesize\' with $format = 10240, \'mimetype\' with $format = \'text/xml\', filename with $format = \'/\\.xml$/\'<br />Validation for files is obviously <b>server-side only</b>'));
$form->addRule('tstUpload', 'Upload is required', 'uploadedfile');
$form->addRule('tstUpload', 'File size should be less than 10kb', 'maxfilesize', 10240);
$form->addRule('tstUpload', 'File type should be text/xml', 'mimetype', 'text/xml');
$form->addRule('tstUpload', 'File name should be *.xml', 'filename', '/\\.xml$/');
$form->addElement('header', null, 'Submit the form');
$submit[] =& $form->createElement('submit', null, 'Send');
$submit[] =& $form->createElement('checkbox', 'clientSide', null, 'use client-side validation', array('checked' => 'checked', 'onclick' => "if (this.checked) {this.form.onsubmit = oldHandler;} else {oldHandler = this.form.onsubmit; this.form.onsubmit = null;}"));
$form->addGroup($submit, null, null, '&nbsp;', false);
$form->applyFilter('__ALL__', 'trim');
$form->validate();
$form->display();
?>

View File

@@ -0,0 +1,115 @@
<?php
/**
* Usage example for HTML_QuickForm, using custom validation rules.
*
* @category HTML
* @package HTML_QuickForm
* @author Alexey Borzov <avb@php.net>
* @version CVS: $Id: rules-custom.php,v 1.3 2007/05/29 19:12:26 avb Exp $
* @ignore
*/
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Rule.php';
/**
* Checks that a numeric value is within range
*
* @package HTML_QuickForm
* @ignore
*/
class RuleNumericRange extends HTML_QuickForm_Rule
{
function validate($value, $options)
{
if (isset($options['min']) && floatval($value) < $options['min']) {
return false;
}
if (isset($options['max']) && floatval($value) > $options['max']) {
return false;
}
return true;
}
function getValidationScript($options = null)
{
$jsCheck = array();
if (isset($options['min'])) {
$jsCheck[] = 'Number({jsVar}) >= ' . $options['min'];
}
if (isset($options['max'])) {
$jsCheck[] = 'Number({jsVar}) <= ' . $options['max'];
}
return array('', "{jsVar} != '' && !(" . implode(' && ', $jsCheck) . ')');
} // end func getValidationScript
}
// In case you are wondering, this checks whether there are too many
// CAPITAL LETTERS in the string
function countUpper($value, $limit = null)
{
if (empty($value)) {
return false;
}
if (!isset($limit)) {
$limit = 0.5;
}
$upper = array_filter(preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY), 'ctype_upper');
return (count($upper) / strlen($value)) <= $limit;
}
// BC thingie: it expects the first param to be element name
function countUpper_old($name, $value, $limit = null)
{
if (empty($value)) {
return false;
}
if (!isset($limit)) {
$limit = 0.5;
}
$upper = array_filter(preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY), 'ctype_upper');
return (count($upper) / strlen($value)) <= $limit;
}
$form =& new HTML_QuickForm('custom');
$form->addElement('header', null, 'Custom rule class');
// registering the custom rule class
$form->registerRule('numRange', null, 'RuleNumericRange');
$form->addElement('text', 'rNumber_1_10', 'The number (1-10):');
$form->addRule('rNumber_1_10', 'Enter number from 1 to 10', 'numRange', array('min' => 1, 'max' => 10), 'client');
// adding an instance of the custom rule class without registering
$form->addElement('text', 'rNonnegative', 'Nonnegative number:');
$form->addRule('rNonnegative', 'Enter nonnegative number', new RuleNumericRange(), array('min' => 0), 'client');
// adding a classname of the custom rule class without registering
$form->addElement('text', 'rNonpositive', 'Nonpositive number:');
$form->addRule('rNonpositive', 'Enter nonpositive number', 'RuleNumericRange', array('max' => 0), 'client');
$form->addElement('header', null, 'Using callbacks');
// using callback without registering
$form->addElement('text', 'rUpper_0_5', 'Some (preferrably lowercase) text:');
$form->addRule('rUpper_0_5', 'There are too many CAPITAL LETTERS', 'callback', 'countUpper');
// register with 'callback' type
$form->registerRule('upper', 'callback', 'countUpper');
$form->addElement('text', 'rUpper_0_25', 'Some (mostly lowercase) text:');
$form->addRule('rUpper_0_25', 'There are too many CAPITAL LETTERS', 'upper', 0.25);
// BC feature: register with 'function' type
$form->registerRule('upperOld', 'function', 'countUpper_old');
$form->addElement('text', 'rUpper_0', 'Some lowercase text:');
$form->addRule('rUpper_0', 'There are CAPITAL LETTERS, this is not allowed', 'upperOld', 0);
$form->addElement('submit', null, 'Send');
$form->applyFilter(array('rUpper_0_5', 'rUpper_0_25', 'rUpper_0'), 'trim');
$form->applyFilter(array('rNumber_1_10', 'rNonnegative', 'rNonpositive'), 'floatval');
$form->validate();
$form->display();
?>