Source for file index.php
Documentation is available at index.php
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<title>Formagic Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
require_once 'Benchmark/Timer.php';
$bench = new Benchmark_Timer();
$bench->setMarker('formagic load');
$def = array('ipName1' => 'defaultVal',
'subitem' => 'default value for subitem',
// $saves = array('ipName1');
$form = new formagic('test', array('method' => 'get'));
$form->setDefaultValues($def);
$pc = $form->addItem('pageController', 'bb');
$p1 = $pc->addItem('page', 'page1');
$p1->addItem('input','subitem',array('label'=> 'sub1', 'blocked' => true));
$data = array('asdf' => 'Val1', 'Val2', 'Val3');
$p1->addItem('select','select1',
'attributes'=> array('style'=> 'background-color:#ffff00',
'onchange' => 'submit()')
$p1i1 = $p1->addItem('input','page1Input2',array('default'=> 'Page1', 'label' => 'dummy'));
$p1i1->addRule('numeric');
// $p1i1->addRule('length', null, array('min' => 10, 'max' => 11));
$data = array(3=> 'Radio1', 84 => 'Radio2', 564 => 'Radio3');
$p1->addItem('radio','radio1', array('label'=> 'gaga',
// 'attributes'=>array('onChange' => 'submit()')
$p1->addItem('pageSwitch', 'page2', array('label' => 'To Page 2'));
$p2 = $pc->addItem('page', 'page2');
$p2->addItem('input','page2Item1',array('default'=> 'Page2, Item1', 'label' => 'dummy'));
$p2->addItem('input','page2Item2',array('default'=> 'Page2, Item2', 'label' => 'dummy2'));
$p2->addItem('pageSwitch', 'page1', array('label' => 'To Page 1'));
$ip1 = $form->addItem('input','ipName1',array('label'=> 'test1', 'default' => 'fad'));
$ip1->addRule('mandatory');
$ip1->setAttributes(array('class'=> 'grml','style'=> 'color:#00aa00'));
$ip2 = $form->addItem('hidden','ipName2',array('label'=> 'test1', 'default' => 'hideme'));
$pw1 = $form->addItem('password','pass',array('label'=> 'geheim:'));
$pw2 = $form->addItem('password','passRepeat',array('label'=> 'geheim:'));
$pw1->addRule('equal', null, $pw2);
// $pw1->addRule('mandatory');
$form->addItem('checkbox','check1',array('label'=> 'check1check2'));
$form->addItem('submit','go',array('label'=> 'los!', 'attributes' => array('style'=> 'color: #ff0000')));
echo "submitted and ok<br />";
// print_r($form->getValues());
$bench->setMarker('build items');
$bench->setMarker('fetch');
|