Source for file FlexyStatic_example.php
Documentation is available at FlexyStatic_example.php
* Example of usage for HTML_QuickForm Object renderer
* with Flexy template engine and static template
* @author Ron McClain <mixtli@cats.ucsc.edu>
* $Id: FlexyStatic_example.php,v 1.4 2004/06/24 19:23:10 ths Exp $
require_once('HTML/Template/Flexy.php');
require_once('HTML/QuickForm.php');
require_once('HTML/QuickForm/Renderer/ObjectFlexy.php');
// 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);
$form->addElement ('hidden', 'session', '1234567890');
$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');
$form->addGroup ($name, 'name', 'Name:', ', ');
$form->addGroup (array ($areaCode, $phoneNo1, $phoneNo2), 'phone',
$form->addElement ('header', 'company_info', 'Company Information');
$form->addElement ('text', 'company', 'Company:', 'size=20');
$form->addGroup ($str, 'street', 'Street:', '<br />');
$form->addGroup ($addr, 'address', 'Zip, city:');
$select = array ('' => 'Please select...', 'AU' => 'Australia', 'FR' =>
'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement ('select', 'country', 'Country:', $select);
$form->addGroup ($checkbox, 'destination', 'Destination:', array (' ',
$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',
$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
// Form is validated, then freezes the data
$form->process ('myProcess', false );
// setup a template object
$options = &PEAR ::getStaticProperty ('HTML_Template_Flexy','options');
'templateDir' => './templates',
'compileDir' => './templates/build',
$template = new HTML_Template_Flexy ($options);
$renderer->setLabelTemplate ("label.html");
$renderer->setHtmlTemplate ("html.html");
$form->accept ($renderer);
$view->form = $renderer->toObject ();
$template->compile ("flexy-static.html");
// capture the array stucture
// render and display the template
$template->outputObject ($view);
Documentation generated on Mon, 11 Mar 2019 14:16:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|