Quickform2 No Renderer Version

This is how a QuickForm2 form looks when you simply output it with Bootstrap loaded, but without a renderer.

Example form legend
Some value here
Small snippet of help text
Example form legend
Example form legend
to

Bootstrap Demo Version

Example form legend
Some value here
Small snippet of help text
Example form legend
@
Example form legend
Note: Labels surround all the options for much larger click areas and a more usable form.
to All times are shown as Pacific Standard Time (GMT -08:00).
Block of help text to describe the field above if need be.
 

The PHP Code

<?php
require_once 'HTML/QuickForm2.php';
require_once 
'HTML/QuickForm2/Container/Group.php';

// Initialize our form object

$form = new HTML_QuickForm2('bootstrap');

// Set some default values

$defaults = array(
    
'uneditableInput' => 'Some value here',
    
'disabledInput' => 'Disabled input here... carry on.',
    
'inlineInputs' => array(
        
'May 1, 2011',
        
'12:00am',
        
'May 8, 2011',
        
'11:59pm'),
    
'optionsRadios' => 'option1'
);
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($defaults));

// First fieldset

$fs1 $form->addFieldset()->setLabel('Example form legend');
$fs1->addText('xlInput', array('class' => 'xlarge'))->setLabel('X-Large input');
$fs1->addSelect('normalSelect')->setLabel("Select")->loadOptions(range(1,5));
$fs1->addSelect('mediumSelect', array('class' => 'medium'))->setLabel("Select")->loadOptions(range(1,5));
$fs1->addSelect('multiSelect', array('class' => 'medium''multiple' => 'multiple'))->setLabel("Multiple select")->loadOptions(range(1,5));

// Uneditable means "Frozen" for QF2

$fs1->addText('uneditableInput')->setLabel('Uneditable input')->toggleFrozen(true);

// Disabled is just "disabled"

$fs1->addText('disabledInput', array('disabled' => 'disabled'))->setLabel('Disabled input')->addClass(array('xlarge''disabled'));
$fs1->addTextarea('textarea', array('disabled' => 'disabled''rows' => 3))->setLabel('Disabled textarea')->addClass(array('xxlarge'));

// Simulate an error

$xlInput $fs1->addText('xlInput2', array('class' => 'xlarge'))->setLabel('X-Large input');
$xlInput->setError('Small snippet of help text');

// Second fieldset

$fs2 $form->addFieldset()->setLabel('Example form legend');
$fs2->addfile('fileInput')->setLabel('File input');



// Third fieldset

$fs3 $form->addFieldset()->setLabel('Example form legend');

// Create a new subclass of group to style checkboxes and radios

class InputList extends HTML_QuickForm2_Container_Group {}
HTML_QuickForm2_Factory::registerElement('inputlist''InputList');

$cbg $fs3->addInputList('optionsCheckboxes')->setLabel(array('List of options''<strong>Note:</strong> Labels surround all the options for much larger click areas and a more usable form.'));
$cbg->addCheckbox(null, array('value' => 'option1'))->setContent("Option one is this and that—be sure to include why it’s great");
$cbg->addCheckbox(null, array('value' => 'option2'))->setContent("Option two can also be checked and included in form results");
$cbg->addCheckbox(null, array('value' => 'option3'))->setContent("Option three can—yes, you guessed it—also be checked and included in form results");
$cbg->addCheckbox(null, array('value' => 'option4''disabled' => 'disabled'))->setContent("Option four cannot be checked as it is disabled.");

class 
InlineInputs extends HTML_QuickForm2_Container_Group {}
HTML_QuickForm2_Factory::registerElement('inlineinputs''InlineInputs');

$drg $fs3->addInlineInputs('inlineInputs')->setLabel(array('Date range''All times are shown as Pacific Standard Time (GMT -08:00).'));
$drg->addText(0)->addclass('small');
$drg->addText(1)->addclass('mini');
$drg->addText(2)->addclass('small');
$drg->addText(3)->addclass('mini');
$drg->setSeparator(array(' ',' to '));

$fs3->addTextarea('textarea', array('rows' => 3))->setLabel(array('Textarea''Block of help text to describe the field above if need be.'))->addClass(array('xxlarge'));

$rag $fs3->addInputList()->setLabel(array('List of options''<strong>Note:</strong> Labels surround all the options for much larger click areas and a more usable form.'));
$rag->addRadio('optionsRadios', array('value' => 'option1'))->setContent("Option one is this and that—be sure to include why it’s great");
$rag->addRadio('optionsRadios', array('value' => 'option2'))->setContent("Option two can is something else and selecting it will deselect options 1");

// The action buttons group

class ActionInputs extends HTML_QuickForm2_Container_Group {}
HTML_QuickForm2_Factory::registerElement('actioninputs''ActionInputs');

$actions $form->addActionInputs();
$actions->addSubmit(null, array('value' => 'Save changes'))->addClass(array('btn''primary'));
$actions->addButton(null, array('type' => 'reset'))->setContent('Cancel')->addClass('btn');

?>