Source for file SmartyDynamic_example.php
Documentation is available at SmartyDynamic_example.php
* Example of usage for HTML_QuickForm Array renderer with Smarty template engine
* @author Thomas Schulz <ths@4bconsult.de>
* @author Alexey Borzov <borz_off@cs.msu.su>
* $Id: SmartyDynamic_example.php,v 1.4 2004/10/15 20:31:00 ths Exp $
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->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', 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 (
array ('Test Select', 'note' => 'We recommend to check at least two categories!'),
array ('A'=> 'A * * * * (luxory)', 'B'=> 'B * * *','C'=> 'C * *','D'=> 'D * (simple)')
$select->setMultiple (true );
$form->addElement ('submit', 'isubTest', 'Test Submit');
$form->addElement ('header', '', 'Grouped Elements');
$form->addGroup ($checkbox, 'ichkABCD', 'ABCD', array (' ', '<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);
// setup a template object
$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)
// render and display the template
$tpl->display ('smarty-dynamic.tpl');
Documentation generated on Mon, 11 Mar 2019 14:16:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|