<h2>A meeting room reservation form</h2>
<p>All fields will be automatically filled with random values - very useful for when debugging forms. The random values will obey the rules set for each element!</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// auto-fill fields with random values
// very useful for when debugging forms
$form->auto_fill();
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array('required' => array('error', 'Name is required!')));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array('required' => array('error', 'Email is required!'), 'email' => array('error', 'Email address seems to be invalid!')));
// "department"
$form->add('label', 'label_department', 'department', 'Department:');
$obj = $form->add('select', 'department', '', array('other' => true));
$obj->add_options(array('Marketing', 'Operations', 'Customer Service', 'Human Resources', 'Sales Department', 'Accounting Department', 'Legal Department'));
$obj->set_rule(array('required' => array('error', 'Department is required!')));
// "room"
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
$obj = $form->add('radios', 'room', array('A' => 'Room A', 'B' => 'Room B', 'C' => 'Room C'));
$obj->set_rule(array('required' => array('error', 'Room selection is required!')));