本文整理汇总了PHP中YDForm::display方法的典型用法代码示例。如果您正苦于以下问题:PHP YDForm::display方法的具体用法?PHP YDForm::display怎么用?PHP YDForm::display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YDForm
的用法示例。
在下文中一共展示了YDForm::display方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
$form->registerFilter('reverse', 'strrev');
$form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'chk2' => false, 'sel1' => 2));
$text =& $form->addElement('text', 'txt1', 'Enter text 1:');
$text->_label = 'new label for txt1';
$form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
$form->addElement('textarea', 'txt3', 'Enter text 2:');
$form->addElement('textareacounter', 'txtcounter_1', 'Textarea counter 1', array(), array('maxlength' => 10, 'before' => ' (', 'after' => ' characters remaining)'));
$form->addElement('textareacounter', 'txtcounter_2', 'Textarea counter 2');
$form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
$form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
$form->addElement('hidden', 'hid1', '');
$form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
$form->addElement('image', 'img1', '', array(), 'http://www.scripting.com/images/xml.gif');
$form->addElement('password', 'pas1', 'Enter your password');
$form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
$form->addElement('checkbox', 'chk1', 'Select me please');
$form->addElement('checkbox', 'chk2', 'Select me please');
$form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
$form->addElement('span', 'span1', 'This is a span. The next element is an image (img).');
$form->addElement('img', 'img2', 'http://www.scripting.com/images/xml.gif');
$form->addElement('file', 'fil1', 'Select an file:');
$form->addElement('submit', 'cmd1', 'Send');
$form->addElement('reset', 'res1', 'Reset');
$form->addFilter('__ALL__', 'upper');
$form->addFilter('txt1', 'trim');
$form->addFilter('txt2', 'reverse');
$form->addRule('txt1', 'required', 'txt1 is required');
$form->addRule('chk2', 'exact', 'chk2 is required', 1);
$form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
YDDebugUtil::dump($form->_regElements, 'Registered elements');
YDDebugUtil::dump($form->_regRules, 'Registered rules');
YDDebugUtil::dump($form->_regFilters, 'Registered filters');
YDDebugUtil::dump($form->_filters, 'Filters');
YDDebugUtil::dump($form->_rules, 'Rules');
YDDebugUtil::dump($form->_formrules, 'Form Rules');
YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
YDDebugUtil::dump($_POST, '$_POST');
YDDebugUtil::dump($_FILES, '$_FILES');
YDDebugUtil::dump($form->toArray());
}
if ($form->validate()) {
YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
YDDebugUtil::dump($form->getValues(), 'Form values');
} else {
$form->display();
}
// Create the form
$form2 = new YDForm('form2');
$form2->setDefaults(array('txt1' => 'First text'));
$form2->addElement('text', 'txt1', 'Enter text 1:');
$form2->addElement('text', 'txt2', 'Enter text 2:');
$form2->addElement('submit', 'cmd1', 'Send');
$form2->display();
}
示例2: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
$elementDate = $form->addElement('dateselect', 'dateSelect1', 'Enter data:');
$elementDate = $form->addElement('dateselect', 'dateSelect2', 'Enter data:');
$elementTime = $form->addElement('timeselect', 'timeSelect1', 'Enter data:');
$elementDateTime = $form->addElement('datetimeselect', 'datetimeSelect1', 'Enter data:');
$form->addElement('submit', 'cmd1', 'Send');
$form->setDefaults(array('dateSelect1' => array('month' => 4, 'day' => 4, 'year' => 2002)));
if (YD_DEBUG == 1) {
YDDebugUtil::dump($form->_regElements, 'Registered elements');
YDDebugUtil::dump($form->_regRules, 'Registered rules');
YDDebugUtil::dump($form->_regFilters, 'Registered filters');
YDDebugUtil::dump($form->_filters, 'Filters');
YDDebugUtil::dump($form->_rules, 'Rules');
YDDebugUtil::dump($form->_formrules, 'Form Rules');
YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
YDDebugUtil::dump($_POST, '$_POST');
YDDebugUtil::dump($_FILES, '$_FILES');
}
if ($form->validate()) {
YDDebugUtil::dump($elementDate->getTimeStamp(), '$elementDate->getTimeStamp()');
YDDebugUtil::dump($elementDate->getTimeStamp('%d/%m/%Y'), '$elementDate->getTimeStamp( "%d/%m/%Y" )');
YDDebugUtil::dump(date('M-d-Y', $elementDate->getTimeStamp()), '$elementDate->gdate( getTimeStamp() )');
YDDebugUtil::dump($elementTime->getTimeStamp(), '$elementTime->getTimeStamp()');
YDDebugUtil::dump($elementTime->getTimeStamp('%H:%M'), '$elementTime->getTimeStamp( "%H:%M" )');
YDDebugUtil::dump($elementDateTime->getTimeStamp(), '$elementDateTime->getTimeStamp()');
YDDebugUtil::dump($elementDateTime->getTimeStamp('%d/%m/%Y %H:%M'), '$elementDateTime->getTimeStamp( "%H:%M" )');
}
$form->display();
}
示例3: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
// Add a first set of elements
$form->addElement('date', 'date1', 'Date1', '');
$form->addElement('date', 'date2', 'Date2 (monthabbr = true)', array('id' => 'mydate'), array('monthabbr' => true));
$form->addElement('date', 'date3', 'Date3 (monthnumber = true)', '', array('monthnumber' => true));
$form->addElement('date', 'date4', 'Date4 (monthucfirst = true)', '', array('monthucfirst' => true));
$form->addElement('date', 'date5', 'Date5 (yearstart = 1970, yearend=2007, yeartwodigits = true)', '', array('yearstart' => 1970, 'yearend' => 2007, 'yeartwodigits' => true));
$form->addElement('date', 'time1', 'Time1', '', array('time'));
$form->addElement('date', 'time2', 'Time2 (minutesoffset = 10)', '', array('time', 'minutesoffset' => 10));
$form->addElement('date', 'time3', 'Time3 (secondsoffset = 15)', '', array('time', 'secondsoffset' => 15));
$form->addElement('date', 'datetime1', 'DateTime1', '', array('datetime'));
$form->addElement('date', 'date6', 'Date6 (month, year)', '', array('month', 'year'));
$form->addElement('date', 'date7', 'Date7 (day, month)', '', array('day', 'month'));
$form->addElement('date', 'date8', 'Date8 (day, hours, minutes)', '', array('day', 'hours', 'minutes'));
$form->addElement('submit', '_cmdSubmit', 'Submit');
// Add rules
$form->addRule(array('date1', 'date2', 'date3', 'date4', 'date5', 'time1', 'time2', 'time3', 'datetime1', 'date6', 'date7', 'date8'), 'date', 'must be a valid date');
if ($form->validate()) {
YDDebugUtil::dump($form->getValues(), '$form->getValues()');
}
// Display form
$form->display();
}
示例4: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
$form->addElement('text', 'text1', 'Enter text 1:');
$form->addElement('text', 'text2', 'Enter text 2:');
$form->addElement('textarea', 'textarea', 'Enter text 3:');
$form->addElement('radio', 'radio1', 'Select a value 1:', array(), array(1 => 'one', 2 => 'two'));
$form->addElement('radio', 'radio2', 'Select a value 2:', array(), array(1 => 'one', 2 => 'two'));
$form->addElement('hidden', 'hidden1', '');
$form->addElement('hidden', 'hidden2', '', array(), 'i am also hidden');
$form->addElement('image', 'image', '', array(), 'http://www.scripting.com/images/xml.gif');
$form->addElement('password', 'password', 'Enter your password');
$form->addElement('bbtextarea', 'bbtextarea', 'Enter your BBCode');
$form->addElement('checkbox', 'checkbox1', 'Check me 1');
$form->addElement('checkbox', 'checkbox2', 'Check me 2');
$form->addElement('select', 'select', 'Select an option:', array(), array(1 => 'one', 2 => 'two'));
$form->addElement('dateselect', 'dateselect', 'Select a date:');
$form->addElement('datetimeselect', 'datetimeselect', 'Select a date:');
$form->addElement('timeselect', 'timeselect', 'Select a date:');
$form->addElement('file', 'file', 'Select an file:');
$form->addElement('submit', 'submit', 'Send');
$form->addElement('button', 'button', 'Button');
$form->addElement('reset', 'resest', 'Reset');
$form->setDefaults(array('radio1' => 1, 'radio2' => 2, 'text1' => 'my text one', 'select' => 1, 'checkbox1' => 'on'));
if ($form->validate()) {
YDDebugUtil::dump($form->getDefaults(), 'Form default values');
YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
YDDebugUtil::dump($form->getValues(), 'Form values');
} else {
$form->display();
}
}
示例5: actionDefault
function actionDefault()
{
// Create the form
echo '<p><b>Compare rule: equal</b></p>';
$form1 = new YDForm('form_equal');
$form1->addElement('text', 'txt1', 'Enter text 1:');
$form1->addElement('text', 'txt2', 'Enter text 2:');
$form1->addElement('text', 'txt3', 'Enter text 3:');
$form1->addElement('submit', 'cmd1', 'equal');
// Add the rules
$form1->addRule('txt1', 'numeric', 'txt1 should be numeric');
$form1->addRule('txt2', 'numeric', 'txt2 should be numeric');
$form1->addRule('txt3', 'numeric', 'txt2 should be numeric');
$form1->addCompareRule(array('txt1', 'txt2', 'txt3'), 'equal', 'txt1, txt2 and txt3 should be equal');
// Validate or show the form
if ($form1->validate()) {
YDDebugUtil::dump($form1->getValues(), 'Form1 values');
} else {
$form1->display();
}
// Create the form
echo '<p><b>Compare rule: asc</b></p>';
$form2 = new YDForm('form_asc');
$form2->addElement('text', 'txt1', 'Enter text 1:');
$form2->addElement('text', 'txt2', 'Enter text 2:');
$form2->addElement('text', 'txt3', 'Enter text 3:');
$form2->addElement('submit', 'cmd1', 'asc');
// Add the rules
$form2->addRule('txt1', 'numeric', 'txt1 should be numeric');
$form2->addRule('txt2', 'numeric', 'txt2 should be numeric');
$form2->addRule('txt3', 'numeric', 'txt2 should be numeric');
$form2->addCompareRule(array('txt1', 'txt2', 'txt3'), 'asc', 'txt1 < txt2 < txt3');
// Validate or show the form
if ($form2->validate()) {
YDDebugUtil::dump($form2->getValues(), 'Form2 values');
} else {
$form2->display();
}
// Create the form
echo '<p><b>Compare rule: desc</b></p>';
$form3 = new YDForm('form_desc');
$form3->addElement('text', 'txt1', 'Enter text 1:');
$form3->addElement('text', 'txt2', 'Enter text 2:');
$form3->addElement('text', 'txt3', 'Enter text 3:');
$form3->addElement('submit', 'cmd1', 'desc');
// Add the rules
$form3->addRule('txt1', 'numeric', 'txt1 should be numeric');
$form3->addRule('txt2', 'numeric', 'txt2 should be numeric');
$form3->addRule('txt3', 'numeric', 'txt2 should be numeric');
$form3->addCompareRule(array('txt1', 'txt2', 'txt3'), 'desc', 'txt1 > txt2 > txt3');
// Validate or show the form
if ($form3->validate()) {
YDDebugUtil::dump($form3->getValues(), 'Form3 values');
} else {
$form3->display();
}
}
示例6: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
$form->registerFilter('reverse', 'strrev');
$form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'sel1' => 2));
$text =& $form->addElement('text', 'txt1', 'Enter text 1:');
$text->_label = 'new label for txt1';
$form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
$form->addElement('textarea', 'txt3', 'Enter text 2:');
$form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
$form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
$form->addElement('hidden', 'hid1', '');
$form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
$form->addElement('image', 'img1', '', array(), 'http://www.yellowduck.be/images/site_images/rss091.gif');
$form->addElement('password', 'pas1', 'Enter your password');
$form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
$form->addElement('checkbox', 'chk1', 'Select me please');
$form->addElement('checkbox', 'chk2', 'Select me please');
$form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
$form->addElement('file', 'fil1', 'Select an file:');
$form->addElement('submit', 'cmd1', 'Send');
$form->addElement('reset', 'res1', 'Reset');
$form->addFilter('__ALL__', 'upper');
$form->addFilter('txt1', 'trim');
$form->addFilter('txt2', 'reverse');
$form->addRule('txt1', 'required', 'txt1 is required');
$form->addRule('chk2', 'required', 'chk2 is required');
$form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
if (YD_DEBUG == 1) {
YDDebugUtil::dump($form->_regElements, 'Registered elements');
YDDebugUtil::dump($form->_regRules, 'Registered rules');
YDDebugUtil::dump($form->_regFilters, 'Registered filters');
YDDebugUtil::dump($form->_filters, 'Filters');
YDDebugUtil::dump($form->_rules, 'Rules');
YDDebugUtil::dump($form->_formrules, 'Form Rules');
YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
YDDebugUtil::dump($_POST, '$_POST');
YDDebugUtil::dump($_FILES, '$_FILES');
}
if ($form->validate()) {
YDDebugUtil::dump($form->getValues(), 'Form values');
} else {
$form->display();
}
// Create the form
$form2 = new YDForm('form2');
$form2->setDefaults(array('txt1' => 'First text'));
$form2->addElement('text', 'txt1', 'Enter text 1:');
$form2->addElement('text', 'txt2', 'Enter text 2:');
$form2->addElement('submit', 'cmd1', 'Send');
$form2->display();
}
示例7: actionDefault
function actionDefault()
{
// create options and attributes
$options = array('pt' => 'Portugal', 'br' => 'Brasil', 'be' => 'Belgium');
$attributes = array('src' => YDUrl::makeLinkAbsolute('./flags/'), 'ext' => 'gif');
// Create the form and add element
$form = new YDForm('form1');
$form->addElement('selectimage', 'si', 'Select country', $attributes, $options);
// Display the template
$form->display();
}
示例8: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
// Add a first set of elements
$elementDate = $form->addElement('dateselect', 'dateSelect1', 'Enter data:');
$elementTime = $form->addElement('timeselect', 'timeSelect1', 'Enter data:');
$elementDateTime = $form->addElement('datetimeselect', 'datetimeSelect1', 'Enter data:');
// Add a second set of elements
$form->addElement('dateselect', 'dateSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
$form->addElement('timeselect', 'timeSelect2', 'Enter data:');
$form->addElement('datetimeselect', 'datetimeSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
$form->addElement('datetimeselect', 'datetimeSelect3', 'Enter data with seconds:', array(), array('seconds' => true));
// Add the send button
$form->addElement('submit', 'cmd1', 'Send');
// Set the defaults
$form->setDefaults(array('dateSelect1' => array('month' => 4, 'day' => 4, 'year' => 2002), 'dateSelect2' => strval(time()), 'timeSelect2' => strval(time()), 'datetimeSelect2' => time() + 3600 * 24));
// Display the form
$form->display();
// Show the contents of the form
if (YDConfig::get('YD_DEBUG') == 1) {
YDDebugUtil::dump($form->_regElements, 'Registered elements');
YDDebugUtil::dump($form->_regRules, 'Registered rules');
YDDebugUtil::dump($form->_regFilters, 'Registered filters');
YDDebugUtil::dump($form->_filters, 'Filters');
YDDebugUtil::dump($form->_rules, 'Rules');
YDDebugUtil::dump($form->_formrules, 'Form Rules');
YDDebugUtil::dump($form->getValue('dateSelect1'), 'dateSelect1');
YDDebugUtil::dump($form->getValue('timeSelect1'), 'timeSelect1');
YDDebugUtil::dump($form->getValue('datetimeSelect1'), 'datetimeSelect1');
YDDebugUtil::dump($form->getValues(), '$form->getValues()');
YDDebugUtil::dump($_POST, '$_POST');
YDDebugUtil::dump($_FILES, '$_FILES');
}
if ($form->validate()) {
YDDebugUtil::dump($form->getValues(), '$form->getValues()');
YDDebugUtil::dump($elementDate->getTimeStamp(), '$elementDate->getTimeStamp()');
YDDebugUtil::dump($elementDate->getTimeStamp('%d/%m/%Y'), '$elementDate->getTimeStamp( "%d/%m/%Y" )');
YDDebugUtil::dump(date('M-d-Y', $elementDate->getTimeStamp()), '$elementDate->gdate( getTimeStamp() )');
YDDebugUtil::dump($elementTime->getTimeStamp(), '$elementTime->getTimeStamp()');
YDDebugUtil::dump($elementTime->getTimeStamp('%H:%M'), '$elementTime->getTimeStamp( "%H:%M" )');
YDDebugUtil::dump($elementDateTime->getTimeStamp(), '$elementDateTime->getTimeStamp()');
YDDebugUtil::dump($elementDateTime->getTimeStamp('%d/%m/%Y %H:%M'), '$elementDateTime->getTimeStamp( "%H:%M" )');
YDDebugUtil::dump(YDStringUtil::formatDate($elementDateTime, 'datetime', 'pt'), 'YDStringUtil::formatDate');
}
}
示例9: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('myForm');
$form->setDefaults(array('name' => 'Joe User'));
$form->addElement('text', 'loginName', 'User name:');
$form->addElement('password', 'loginPass', 'Password:');
$form->addElement('submit', 'cmdSubmit', 'Login');
// Add the form rule
$form->addFormRule(array(&$this, 'checkLogin'));
// Process the form
if ($form->validate()) {
YDDebugUtil::dump($form->getValues());
} else {
$form->display();
}
}
示例10: actionDefault
function actionDefault()
{
// create form
$form = new YDForm('myform');
// add elements
$form->addElement('text', 'txt', 'Enter your name:');
$form->addElement('captcha', 'cap', 'Enter code:');
$form->addElement('submit', 'cmd', 'Send');
// add rules
$form->addRule('txt', 'required', 'Your name is required');
$form->addRule('cap', 'captcha', 'Security code is not valid');
if ($form->validate()) {
YDDebugUtil::dump($form->getValues(), 'Form values');
} else {
$form->display();
}
}
示例11: actionDefault
function actionDefault()
{
// Create the form
$form = new YDForm('form1');
// Add elements
$form->addElement('text', 'username', 'Fill a username that starts with spaces');
$form->addElement('text', 'name', 'Fill a small caps name');
$form->addElement('datetimeselect', 'date1', 'Date1');
$form->addElement('date', 'date2', 'Date2');
$form->addElement('datetimeselect', 'date3', 'Date3');
$form->addElement('datetimeselect', 'date4', 'Date4');
$form->addElement('submit', '_cmdSubmit', 'Submit');
// Some defaults
$form->setDefault('username', ' myuser');
$form->setDefault('name', 'igor');
// Add filters
$form->addFilter('username', 'trim');
// must return eg 'myuser'
$form->addFilter('name', 'upper');
// must return eg 'IGOR'
if ($form->validate()) {
// IMPORTANT NOTE: 'dateformat' filters must be always added AFTER form validation !
// On form validation checking (by $form->validate()), 'dateformat' filter is applyed and
// element is not populated again because date result array is lost.
// This is why form is not displayed correctly after validation
// (if some rule is broken you would not get the date element with correct values)
$form->addFilter('date2', 'dateformat', 'day');
// must return eg '20'
$form->addFilter('date3', 'dateformat', 'datetimesql');
// must return eg '2005-02-01 10:00:00'
$form->addFilter('date4', 'dateformat', "%b");
// must return eg 'Aug'
YDDebugUtil::dump($form->getValues(), '$form->getValues()');
} else {
// Display form
$form->display();
}
}