Source for file FlexyDynamic_example.php
Documentation is available at FlexyDynamic_example.php
* Example of usage for HTML_QuickForm Object renderer
* with Flexy template engine and dynamic template
* @author Ron McClain <mixtli@cats.ucsc.edu>
* $Id: FlexyDynamic_example.php,v 1.2 2003/11/03 12:55:53 avb Exp $
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/Object.php';
require_once 'HTML/Template/Flexy.php';
$form->setDefaults (array (
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'iselTest' => array ('B', 'C'),
'name' => array ('first' => 'Thomas', 'last' => 'Schulz'),
'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->setMultiple (true );
$form->addElement ('submit', 'isubTest', 'Test Submit');
$form->addElement ('header', '', 'Grouped Elements');
$form->addGroup ($checkbox, 'ichkABCD', 'ABCD', '<br />');
// will be later assigned to style fancygroup
$form->addGroup ($radio, 'iradYesNo', 'Yes/No');
// will be later assigned to style fancygroup
$name['first']->setSize (20 );
$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
// give some elements aditional style informations
$renderer->setElementStyle (array (
'iradYesNo' => 'fancygroup',
$form->accept ($renderer);
$options = &PEAR ::getStaticProperty ('HTML_Template_Flexy','options');
'templateDir' => './templates',
'compileDir' => './templates/build',
$tpl = & new HTML_Template_Flexy ($options);
//$tpl->compile("styles/green.html");
//$tpl->compile("styles/fancygroup.html");
// assign array with form data
$view->form = $renderer->toObject ();
// capture the array stucture
// (only for showing in sample template)
// XXX: dunno how to make Flexy ignore the placeholder
$view->formdata = '{formdata}';
// render and display the template
$tpl->compile ('flexy-dynamic.html');
$tpl->outputObject ($view);
Documentation generated on Mon, 11 Mar 2019 14:16:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|