Source for file basic-elements.php
Documentation is available at basic-elements.php
* Usage example for HTML_QuickForm2 package: basic elements
* $Id: basic-elements.php 288268 2009-09-11 13:50:48Z avb $
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
/* Set up custom font and form width */
font-family: Arial,sans-serif;
/* Use default styles included with the package */
if ('@data_dir@' != '@' . 'data_dir@') {
$filename = '@data_dir@/HTML_QuickForm2/data/quickform.css';
<title>HTML_QuickForm2 basic elements example</title>
'a' => 'Letter A', 'b' => 'Letter B', 'c' => 'Letter C',
'd' => 'Letter D', 'e' => 'Letter E', 'f' => 'Letter F'
require_once 'HTML/QuickForm2.php';
// data source with default values:
'textTest' => 'Some text',
'areaTest' => "Some text\non multiple lines",
'selMultipleTest' => array ('b', 'c'),
$fsText = $form->addElement ('fieldset')->setLabel ('Text boxes');
'text', 'textTest', array ('style' => 'width: 300px;'), array ('label' => 'Test Text:')
'password', 'pwdTest', array ('style' => 'width: 300px;'), array ('label' => 'Test Password:')
$area = $fsText->addElement (
'textarea', 'areaTest', array ('style' => 'width: 300px;', 'cols' => 50 , 'rows' => 7 ),
array ('label' => 'Test Textarea:')
$fsNested = $form->addElement ('fieldset')->setLabel ('Nested fieldset');
'text', 'userTest', array ('style' => 'width: 200px'), array ('label' => 'Username:')
'password', 'passTest', array ('style' => 'width: 200px'), array ('label' => 'Password:')
// Now we move the fieldset into another fieldset!
$fsText->insertBefore ($fsNested, $area);
$fsSelect = $form->addElement ('fieldset')->setLabel ('Selects');
'select', 'selSingleTest', null , array ('options' => $options, 'label' => 'Single select:')
'select', 'selMultipleTest', array ('multiple' => 'multiple', 'size' => 4 ),
array ('options' => $options, 'label' => 'Multiple select:')
$fsCheck = $form->addElement ('fieldset')->setLabel ('Checkboxes and radios');
'checkbox', 'boxTest', null , array ('content' => 'check me', 'label' => 'Test Checkbox:')
'radio', 'radioTest', array ('value' => 1 ), array ('content' => 'select radio #1', 'label' => 'Test radio:')
'radio', 'radioTest', array ('value' => 2 ), array ('content' => 'select radio #2', 'label' => '(continued)')
$fsButton = $form->addElement ('fieldset')->setLabel ('Buttons');
$testReset = $fsButton->addElement (
'reset', 'testReset', array ('value' => 'This is a reset button')
'inputbutton', 'testInputButton',
array ('value' => 'Click this button', 'onclick' => "alert('This is a test.');")
'button', 'testButton', array ('onclick' => "alert('Almost nothing');", 'type' => 'button'),
array ('content' => '<img src="http://pear.php.net/gifs/pear-icon.gif" '.
'width="32" height="32" alt="pear" />This button does almost nothing')
// submit buttons in nested fieldset
$fsSubmit = $fsButton->addElement ('fieldset')->setLabel ('These buttons can submit the form');
'submit', 'testSubmit', array ('value' => 'Test Submit')
'button', 'testSubmitButton', array ('type' => 'submit'),
array ('content' => '<img src="http://pear.php.net/gifs/pear-icon.gif" '.
'width="32" height="32" alt="pear" />This button submits')
'image', 'testImage', array ('src' => 'http://pear.php.net/gifs/pear-icon.gif')
// outputting form values
if ('POST' == $_SERVER['REQUEST_METHOD']) {
// let's freeze the form and remove the reset button
$fsButton->removeChild ($testReset);
$form->toggleFrozen (true );
Documentation generated on Mon, 11 Mar 2019 15:34:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|