// Include the FormBuilder
include_once(‘/formbuilder/FormBuilder.php’);

// Create the settings
$settings = array( ‘name’ => ‘exampleForm’, ‘action’ => ‘/examples.php’, ‘title’ => ‘Example form’);

// Create the fields
$fields = array(
array(‘name’ => ‘exampleTextField’, ‘type’ => ‘text’, ‘label’ => ‘This is a textfield’,
‘placeholder’ => ‘Placeholder shows up here’),
array(‘id’ => ‘exampleCheckBox’, ‘name’ => ‘exampleCheckBox’, ‘type’ => ‘checkbox’,
‘label’ => ‘A nicely styled checkbox’, ‘valueLabel’ => ‘Can I be checked?’,
‘checked’ => true),
array(‘id’ => ‘differentCheckBox’, ‘name’ => ‘differentCheckBox’, ‘type’ => ‘checkbox’,
‘valueLabel’ => ‘What about me?’),
array(‘name’ => ‘exampleRadioButton’, ‘type’ => ‘radio’,
‘label’ => ‘A nice looking radio button’,
‘options’ => array(array(‘value’ => ‘1’, ‘label’ => ‘First option’, ‘checked’ => true),
array(‘value’ => ‘2’, ‘label’ => ‘Second option’),
array(‘value’ => ‘3’, ‘label’ => ‘Third option’))),
array(‘name’ => ‘exampleSelectBox’, ‘type’ => ‘select’, ‘label’ => ‘A dropdown box as well’,
‘options’ => array(array(‘value’ => ‘value1’, ‘label’ => ‘First option’),
array(‘value’ => ‘value2’, ‘label’ => ‘Second option’),
array(‘value’ => ‘value3’, ‘label’ => ‘Third option’))),
array(‘name’ => ‘exampleTextArea’, ‘type’ => ‘textarea’,
‘label’ => ‘We can add a textarea as well’, ‘placeholder’ => ‘And add a placeholder’),
array(‘name’ => ‘examplePasswordField’, ‘type’ => ‘password’,
‘label’ => ‘We provide a special password field’,
‘placeholder’ => ‘Password will be displayed as stars, just try it out!’),
array(‘name’ => ‘exampleNumberField’, ‘type’ => ‘number’,
‘label’ => ‘And a specific numeric field’,
‘placeholder’ => ‘Only numbers (0-9) are accepted as a value!’),
array(‘name’ => ‘exampleFileInputField’, ‘type’ => ‘file’,
‘label’ => ‘A custom styled file input field’,
‘onchange’ => ‘this.nextSibling.innerHTML=this.value.replace(/^.*[\\\/]/, \’\’);’),
array(‘id’ => ‘exampleToggleBox’, ‘name’ => ‘exampleToggleBox’, ‘type’ => ‘toggle’,
‘label’ => ‘A nicely styled On-Off switch’, ‘value’ => ‘on’),
array(‘id’ => ‘exampleRatingButton’, ‘name’ => ‘exampleRatingButton’, ‘type’ => ‘rating’,
‘label’ => ‘We can rate stuff too’,
‘options’ => array(array(‘value’ => ‘first’),
array(‘value’ => ‘second’),
array(‘value’ => ‘third’),
array(‘value’ => ‘fourth’),
array(‘value’ => ‘fifth’))),
array(‘name’ => ‘exampleRangeField’, ‘type’ => ‘range’, ‘label’ => ‘And a modern day slider’),
array(‘name’ => ‘exampleDateField’, ‘type’ => ‘date’, ‘label’ => ‘Includes a date field as well’)
);

// Actually create the FormBuilder
$formbuilder = new FormBuilder($settings, $fields);

// Print the resulting form
echo $formbuilder->toString();