Example #1
0
/**
 *  PhpLiteFormBuilder Sample
 *  @author Martin Forejt
 *  https://github.com/MFori
 */
include '../FormBuilder/Form.php';
// FormBuilder use super global variable $_SESSION
session_start();
// create new Form
$mForm = new Form('mForm', 'post');
// adding elements
// open part 'customer'
$mForm->openPart('customer');
$mForm->addElement(new InputText(), true)->setName('name')->setId('name')->setLabel(new Label('Name:'));
$mForm->addElement(new InputText(), true)->setName('surname')->setId('surname')->setLabel(new Label('Surname:'));
$mForm->closePart();
// open part 'address'
$mForm->openPart('address');
$mForm->addElement(new InputText())->setName('street')->setId('street')->setLabel(new Label('Street:'));
$mForm->addElement(new InputText())->setName('city')->setId('city')->setLabel(new Label('City:'));
$mForm->addElement(new InputText())->setName('state')->setId('state')->setLabel(new Label('State:'));
$mForm->closePart();
// open part 'agreement'
$mForm->openPart('agreement');
$mForm->addElement(new InputCheckBox(), true)->setName('agree')->setId('agree')->setLabel(new Label('I accept the terms and conditions'));
$mForm->addElement(new InputSubmit())->setValue('Sent');
$mForm->closePart();
// create from
$mForm->create();
echo '<h2>Address</h2>';
//render 'address'