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


PHP HTML_QuickForm2::setAttribute方法代碼示例

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


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

示例1: testIdAndMethodAreReadonly

 public function testIdAndMethodAreReadonly()
 {
     $form = new HTML_QuickForm2('foo', 'get');
     try {
         $form->removeAttribute('id');
     } catch (HTML_QuickForm2_InvalidArgumentException $e) {
         try {
             $form->setAttribute('method', 'post');
         } catch (HTML_QuickForm2_InvalidArgumentException $e) {
             try {
                 $form->setId('newId');
             } catch (HTML_QuickForm2_InvalidArgumentException $e) {
                 return;
             }
         }
     }
     $this->fail('Expected HTML_QuickForm2_InvalidArgumentException was not thrown');
 }
開發者ID:manishkhanchandani,項目名稱:mkgxy,代碼行數:18,代碼來源:QuickForm2Test.php

示例2: check_password

        output_element($element);
    }
    echo "</fieldset>\n";
}
// in real application the password check will a bit be different, of course
function check_password($password)
{
    return $password == 'qwerty';
}
//
// Form setup
//
require_once 'HTML/QuickForm2.php';
$form = new HTML_QuickForm2('basicRules');
// for file upload to work
$form->setAttribute('enctype', 'multipart/form-data');
// data source with default values:
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('testUsername' => 'luser')));
// override whatever value was submitted
$form->addElement('hidden', 'MAX_FILE_SIZE')->setValue('102400');
//
// Simple fields validation, rule chaining
//
$fsAuth = $form->addElement('fieldset')->setLabel('Auth credentials');
$username = $fsAuth->addElement('text', 'testUsername', array('style' => 'width: 200px;'))->setLabel('Username (letters only):');
$fsPasswords = $fsAuth->addElement('fieldset')->setLabel('Supply password only if you want to change it');
$oldPassword = $fsPasswords->addElement('password', 'oldPassword', array('style' => 'width: 200px;'))->setLabel('Old password (<i>qwerty</i>):');
$newPassword = $fsPasswords->addElement('password', 'newPassword', array('style' => 'width: 200px;'))->setLabel('New password (min 6 chars):');
$repPassword = $fsPasswords->addElement('password', 'newPasswordRepeat', array('style' => 'width: 200px;'))->setLabel('Repeat new password:');
$username->addRule('required', 'Username is required');
$username->addRule('regex', 'Username should contain only letters', '/^[a-zA-Z]+$/');
開發者ID:manishkhanchandani,項目名稱:mkgxy,代碼行數:31,代碼來源:builtin-rules.php


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