當前位置: 首頁>>代碼示例>>PHP>>正文


PHP YDForm::render方法代碼示例

本文整理匯總了PHP中YDForm::render方法的典型用法代碼示例。如果您正苦於以下問題:PHP YDForm::render方法的具體用法?PHP YDForm::render怎麽用?PHP YDForm::render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在YDForm的用法示例。


在下文中一共展示了YDForm::render方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1', 'GET', '', '_self', array('class' => 'myform'));
     // Add elements
     $form->addElement('text', 'txt1', 'Enter text 1:');
     $form->addElement('text', 'txt2', 'Enter text 2:');
     $form->addElement('submit', 'cmdSubmit', 'submit');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('txt1', 'maxlength', 'txt1 must be smaller than 15', 15);
     $form->addCompareRule(array('txt1', 'txt2'), 'equal', 'txt1 and txt2 must be equal');
     $form->addFormRule('formrule1');
     $form->addFormRule(array('YDValidateRule', 'formrule2'));
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'trim');
     // Convert the form to XML
     $xml = $form->render('xml');
     YDDebugUtil::dump($xml, 'Form as XML data');
     //YDDebugUtil::dump( $form );
     // Recreate a new form from the XML data
     $form2 = new YDForm('form1');
     $form2->import('xml', $xml);
     //YDDebugUtil::dump( $form2 );
     YDDebugUtil::dump(array_diff_assoc($form->toArray(), $form2->toArray()), 'toArray difference');
     YDDebugUtil::dump(array_diff_assoc($form->_attributes, $form2->_attributes), '_attributes difference');
     YDDebugUtil::dump(array_diff_assoc($form->_elements, $form2->_elements), '_elements difference');
     YDDebugUtil::dump(array_diff_assoc($form->_rules, $form2->_rules), '_rules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_filters, $form2->_filters), '_filters difference');
     YDDebugUtil::dump(array_diff_assoc($form->_comparerules, $form2->_comparerules), '_comparerules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_formrules, $form2->_formrules), '_formrules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regElements, $form2->_regElements), '_regElements difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regRules, $form2->_regRules), '_regRules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regFilters, $form2->_regFilters), '_regFilters difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regRenderers, $form2->_regRenderers), '_regRenderers difference');
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:35,代碼來源:form_xml2.php

示例2: actionDefault

 function actionDefault()
 {
     // create a form with two select buttons
     $form = new YDForm('myform');
     $form->addElement('select', 'car', '', array(), array('Please select your car', 'Ferrari', 'Fiat', 'BMW'));
     $form->addElement('select', 'model', '', array());
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // register event to element 'car' and send to 'getmodel' method its dynamic value
     $this->ajax->addEvent('car', array(&$this, 'getmodel'), array('car'));
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'Dependency with two select elements:');
     $this->tpl->assign('form', $form->render('html'));
     $this->tpl->display('general');
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:16,代碼來源:cars.php

示例3: actionDefault

 function actionDefault()
 {
     // create form
     $form = new YDForm('myform');
     $form->addElement('text', 'mytext', 'Write something, eg: "David" (case sensitive)');
     $form->addElement('select', 'items', '', array(), array('Francisco' => 'Francisco', 'Pieter' => 'Pieter', 'David' => 'David'));
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // assign event to mytext
     $this->ajax->addEvent('mytext', array(&$this, 'setSelect'), 'mytext', 'onkeyup');
     // process all events
     $this->ajax->processEvents();
     // assign title, form and display template
     $this->tpl->assign('title', 'Change selected value on-the-fly example');
     $this->tpl->assign('form', $form->render('html'));
     $this->tpl->display('general');
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:17,代碼來源:select_option.php


注:本文中的YDForm::render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。