[geeklog-cvs] MVCnPHP/quickform/views QFExampleOne.class.php,NONE,1.1
geeklog-cvs-admin at lists.geeklog.net
geeklog-cvs-admin at lists.geeklog.net
Fri May 2 14:00:41 EDT 2003
Update of /usr/cvs/geeklog/MVCnPHP/quickform/views
In directory internal.geeklog.net:/tmp/cvs-serv25395/views
Added Files:
QFExampleOne.class.php
Log Message:
Initial release for QuickForm example
--- NEW FILE: QFExampleOne.class.php ---
<?php
require_once '../QF_View.class.php';
class QFExampleOne extends QF_View {
function getView()
{
$this->_setQFormAttributes('frmTest','get');
// Fills with some defaults values
$defaultValues['itxtTest'] = 'Test Text Box';
$defaultValues['itxaTest'] = 'Hello World';
$defaultValues['ichkTest'] = true;
$defaultValues['iradTest'] = 1;
$defaultValues['iselTest'] = array('B', 'C');
$defaultValues['name'] = array('first'=>'Adam', 'last'=>'Daniel');
$defaultValues['phoneNo'] = array('513', '123', '3456');
$defaultValues['iradYesNo'] = 'Y';
$defaultValues['ichkABC'] = array('A'=>true,'B'=>true);
$defaultValues['QFText'] = '153.5';
$defaultValues['dateTest1'] = array('d'=>11, 'm'=>1, 'Y'=>2003);
$this->_QForm->setDefaults($defaultValues);
$constantValues['dateTest3'] = time();
$this->_QForm->setConstants($constantValues);
// Elements will be displayed in the order they are declared
$this->_QForm->addHeader('Normal Elements');
// Classic form elements
$this->_QForm->addElement('hidden', 'ihidTest', 'hiddenField');
$this->_QForm->addElement('hidden','cmd','validate');
$this->_QForm->addElement('text', 'itxtTest', 'Test Text:');
$this->_QForm->addElement('textarea', 'itxaTest', 'Test TextArea:');
$this->_QForm->addElement('password', 'ipwdTest', 'Test Password:');
//$this->_QForm->addElement('file', 'ifilTest', 'File:');
$this->_QForm->addElement('checkbox', 'ichkTest', 'Test CheckBox:', 'Check the box');
$this->_QForm->addElement('radio', 'iradTest', 'Test Radio Buttons:', 'Check the radio button #1', 1);
$this->_QForm->addElement('radio', 'iradTest', '(Not a group)', 'Check the radio button #2', 2);
$this->_QForm->addElement('button', 'ibtnTest', 'Test Button');
$this->_QForm->addElement('reset', 'iresTest', 'Test Reset');
$this->_QForm->addElement('submit', 'isubTest', 'Test Submit');
$this->_QForm->addElement('image', 'iimgTest', 'http://www.php.net/gifs/php_logo.gif');
$this->_QForm->addElement('select', 'iselTest', 'Test Select:', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
$select = &$this->_QForm->getElement('iselTest');
$select->setSize(5);
$select->setMultiple(true);
$this->_QForm->addHeader('Date Elements');
// Date elements
$this->_QForm->addElement('date', 'dateTest1', 'Date1:', array('format'=>'dmY', 'minYear'=>2000, 'maxYear'=>2004));
$this->_QForm->addElement('date', 'dateTest2', 'Date2:', array('format'=>'d-F-Y', 'language'=>'de'));
$this->_QForm->addElement('date', 'dateTest3', 'Today is:', array('format'=>'l D d M Y'));
$this->_QForm->addHeader('Grouped Elements');
// Grouped elements
$name['last'] = &HTML_QuickForm::createElement('text', 'last');
$name['last']->setSize(30);
$name['first'] = &HTML_QuickForm::createElement('text', 'first');
$name['first']->setSize(20);
$this->_QForm->addGroup($name, 'name', 'Name (last, first):', ', ');
// Creates a group of text inputs
$areaCode = &HTML_QuickForm::createElement('text', '');
$areaCode->setSize(3);
$areaCode->setMaxLength(3);
$phoneNo1 = &HTML_QuickForm::createElement('text', '');
$phoneNo1->setSize(3);
$phoneNo1->setMaxLength(3);
$phoneNo2 = &HTML_QuickForm::createElement('text', '');
$phoneNo2->setSize(4);
$phoneNo2->setMaxLength(4);
$this->_QForm->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phoneNo', 'Telephone:', '-');
// Creates a radio buttons group
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$this->_QForm->addGroup($radio, 'iradYesNo', 'Yes/No:');
// Creates a checkboxes group
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$this->_QForm->addGroup($checkbox, 'ichkABC', 'ABC:', '<br />');
// Creates a group of buttons to be displayed at the bottom of the form
$buttons[] = &HTML_QuickForm::createElement('submit', null, 'Submit');
$buttons[] = &HTML_QuickForm::createElement('reset', null, 'Reset');
$buttons[] = &HTML_QuickForm::createElement('image', 'iimgTest', '/images/apache_pb.gif');
$buttons[] = &HTML_QuickForm::createElement('button', 'ibutTest', 'Test Button');
$this->_QForm->addGroup($buttons);
$this->_QForm->addHeader('Using the form element classes directly');
$text = new HTML_QuickForm_text('QFText', 'QuickForm Text:');
$this->_QForm->addElement($text);
// applies new filters to the element values
$this->_QForm->applyFilter('__ALL__', 'trim');
$this->_QForm->applyFilter('QFText', 'doubleval');
// applies new filters to the element values
$this->_QForm->applyFilter('__ALL__', 'trim');
$this->_QForm->applyFilter('QFText', 'doubleval');
// Adds some validation rules
$this->_QForm->addRule('itxtTest', 'Test Text is a required field', 'required');
$this->_QForm->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$this->_QForm->addRule('itxaTest', 'Test TextArea must be at least 5 characters', 'minlength', '5');
$this->_QForm->addRule('ipwdTest', 'Password must be between 8 to 10 characters', 'rangelength', '8,10');
$this->_QForm->addRule('QFText', 'Value must be numeric', 'numeric', '', 'client');
if ($this->_QForm->validate()) {
$this->_QForm->freeze();
$this->_QForm->process();
echo "\n<HR>\n";
}
$this->_QForm->display();
}
function execute()
{
$this->getView();
}
}
?>
More information about the geeklog-cvs
mailing list