<?php
/**
* Moc10 Library
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.TXT.
* It is also available through the world-wide-web at this URL:
* http://www.moc10phplibrary.com/LICENSE.TXT
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to hide@address.com so we can send you a copy immediately.
*
* @category Moc10
* @package Moc10_Form
* @author Nick Sagona, III <hide@address.com>
* @copyright Copyright (c) 2009-2011 Moc 10 Media, LLC. (http://www.moc10media.com)
* @license http://www.moc10phplibrary.com/LICENSE.TXT New BSD License
*/
/**
* Test_Form_ContactAlt
*
* @category Moc10
* @package Moc10_Form
* @author Nick Sagona, III <hide@address.com>
* @copyright Copyright (c) 2009-2011 Moc 10 Media, LLC. (http://www.moc10media.com)
* @license http://www.moc10phplibrary.com/LICENSE.TXT New BSD License
* @version 1.9.7
*/
class Test_Form_ContactAlt extends Moc10_Form
{
/**
* Contact form template
* @var string
*/
protected $_template = null;
/**
* Initialization method for the test contact form.
*
* @return void
*/
public function init()
{
$this->_setTemplate();
$this->setAttributes('id', 'loginForm');
// Create the 'name' form element.
$name = new Moc10_Form_Element('text', 'name');
$name->setLabel('Name:');
$name->setAttributes('size', '40');
$name->addValidator('AlphaNum');
$name->setRequired(true);
// Create the 'email' form element.
$email = new Moc10_Form_Element('text', 'email');
$email->setLabel('Email:');
$email->setAttributes('size', '40');
$email->addValidator('Email');
$email->setRequired(true);
// Create the 'gender' select form element.
$gender = new Moc10_Form_Element_Select('gender', array('----' => '----', 'Male' => 'Male', 'Female' => 'Female'));
$gender->setLabel('Gender:');
$gender->addValidator('NotEqual', true, '----');
$gender->setAttributes('class', 'selectField');
$gender->setAttributes('onchange', "doSomeMoreJS('loginForm');");
// Create the 'subscribe' radio form element.
$subscribe = new Moc10_Form_Element_Radio('subscribe', array('Yes' => 'Yes', 'No' => 'No', 'Maybe' => 'Maybe', 'IDK' => 'I Dont Know, OK!'));
$subscribe->setLabel('Subscribe:');
// Create the 'colors' checkbox form element.
$colors = new Moc10_Form_Element_Checkbox('colors', array('Red' => 'Red', 'White' => 'White', 'Blue' => 'Blue'));
$colors->setLabel('Colors:');
// Create the 'comments' textarea form element.
$comments = new Moc10_Form_Element_Textarea('comments');
$comments->setLabel('Questions/Comments:');
$comments->setAttributes('rows', '5');
$comments->setAttributes('cols', '40');
$comments->setRequired(true);
// Create the 'submit' form element.
$submit = new Moc10_Form_Element('submit', 'submit', 'Send');
$submit->setAttributes('class', 'submitBtn');
// Set the form template and add the form element objects to the form.
$this->setTemplate($this->_template);
$this->addElements(array($name, $email, $gender, $subscribe, $colors, $comments, $submit));
}
/**
* Method to process the form data.
*
* @return void
*/
public function process()
{
// Form processing code can go here.
print('The form has been successfully processed.');
}
/**
* Method to set the form template.
*
* @return void
*/
protected function _setTemplate()
{
// Define the form template.
$this->_template = <<<FORMTEMP
<table>
<tr>
<td>
[{name_label}]
</td>
<td>
[{name}]
</td>
</tr>
<tr>
<td>
[{email_label}]
</td>
<td>
[{email}]
</td>
</tr>
<tr>
<td>
[{gender_label}]
</td>
<td>
[{gender}]
</td>
</tr>
<tr>
<td>
[{subscribe_label}]
</td>
<td>
[{subscribe}]
</td>
</tr>
<tr>
<td>
[{colors_label}]
</td>
<td>
[{colors}]
</td>
</tr>
<tr>
<td>
[{comments_label}]
</td>
<td>
[{comments}]
</td>
</tr>
<tr>
<td>
</td>
<td>
[{submit}]
</td>
</tr>
</table>
FORMTEMP;
}
}