当前位置: 首页>>代码示例>>PHP>>正文


PHP HTML_QuickForm2类代码示例

本文整理汇总了PHP中HTML_QuickForm2的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2类的具体用法?PHP HTML_QuickForm2怎么用?PHP HTML_QuickForm2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HTML_QuickForm2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBug20295

 /**
  * If data source contains explicitly provided null values, those should be used
  * @link http://pear.php.net/bugs/bug.php?id=20295
  */
 public function testBug20295()
 {
     $form = new HTML_QuickForm2('bug20295');
     $hs = $form->addHierselect('hs')->loadOptions(array($this->_primary, $this->_secondary))->setValue(array(1, 12));
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('hs' => null)));
     $this->assertNull($hs->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:11,代码来源:HierselectTest.php

示例2: testSetValueFromSubmitDataSource

 public function testSetValueFromSubmitDataSource()
 {
     $form = new HTML_QuickForm2('image', 'post', null, false);
     $foo = $form->appendChild(new HTML_QuickForm2_Element_InputImage('foo'));
     $bar = $form->appendChild(new HTML_QuickForm2_Element_InputImage('bar[idx]'));
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('foo_x' => '1234', 'foo_y' => '5678', 'bar' => array('idx' => array('98', '76')))));
     $this->assertEquals(array('x' => '12', 'y' => '34'), $foo->getValue());
     $this->assertEquals(array('x' => '56', 'y' => '78'), $bar->getValue());
     $foo->setAttribute('disabled');
     $this->assertNull($foo->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:11,代码来源:InputImageTest.php

示例3: testSetValueFromSubmitDataSource

 public function testSetValueFromSubmitDataSource()
 {
     $form = new HTML_QuickForm2('submit', 'post', null, false);
     $foo = $form->appendChild(new HTML_QuickForm2_Element_InputSubmit('foo'));
     $bar = $form->appendChild(new HTML_QuickForm2_Element_InputSubmit('bar'));
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('foo' => 'Default for foo', 'bar' => 'Default for bar')));
     $this->assertEquals('A button clicked', $foo->getValue());
     $this->assertNull($bar->getValue());
     $foo->setAttribute('disabled');
     $this->assertNull($foo->getValue());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:11,代码来源:InputSubmitTest.php

示例4: testGroupHiddens

 public function testGroupHiddens()
 {
     $form = new HTML_QuickForm2('testGroupHiddens', 'post', null, false);
     $hidden = $form->addHidden('aHiddenElement');
     $renderer = HTML_QuickForm2_Renderer::factory('stub');
     $renderer->setOption('group_hiddens', false);
     $form->render($renderer);
     $this->assertEquals(array(), $renderer->getHidden());
     $renderer->setOption('group_hiddens', true);
     $form->render($renderer);
     $this->assertEquals(array($hidden->__toString()), $renderer->getHidden());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:12,代码来源:StubTest.php

示例5: addElement

 /**
  * Wrapper around HTML_QuickForm2_Container's addElement()
  *
  * @param    string|HTML_QuickForm2_Node  Either type name (treated
  *               case-insensitively) or an element instance
  * @param    mixed   Element name
  * @param    mixed   Element attributes
  * @param    array   Element-specific data
  * @return   HTML_QuickForm2_Node     Added element
  * @throws   HTML_QuickForm2_InvalidArgumentException
  * @throws   HTML_QuickForm2_NotFoundException
  */
 public function addElement($elementOrType, $name = null, $attributes = null, array $data = array())
 {
     if ($name != 'submit') {
         $this->a_formElements[] = $name;
     }
     return parent::addElement($elementOrType, $name, $attributes, $data);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:19,代码来源:QuickForm2.php

示例6: testPerform

 public function testPerform()
 {
     $formOne = new HTML_QuickForm2('formOne');
     $formOne->addElement('text', 'foo')->setValue('foo value');
     $pageOne = $this->getMock('HTML_QuickForm2_Controller_Page', array('populateForm'), array($formOne));
     $formTwo = new HTML_QuickForm2('formTwo');
     $formTwo->addElement('text', 'bar')->setValue('bar value');
     $pageTwo = $this->getMock('HTML_QuickForm2_Controller_Page', array('populateForm'), array($formTwo));
     $mockJump = $this->getMock('HTML_QuickForm2_Controller_Action', array('perform'));
     $mockJump->expects($this->exactly(2))->method('perform')->will($this->returnValue('jump to foo'));
     $pageOne->addHandler('jump', $mockJump);
     $controller = new HTML_QuickForm2_Controller('testBackAction');
     $controller->addPage($pageOne);
     $controller->addPage($pageTwo);
     $this->assertEquals('jump to foo', $pageTwo->handle('back'));
     $this->assertEquals(array(), $controller->getSessionContainer()->getValues('formOne'));
     $this->assertContains('bar value', $controller->getSessionContainer()->getValues('formTwo'));
     $this->assertEquals('jump to foo', $pageOne->handle('back'));
     $this->assertContains('foo value', $controller->getSessionContainer()->getValues('formOne'));
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:20,代码来源:BackTest.php

示例7: renderForm

    protected function renderForm(HTML_QuickForm2 $form)
    {
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
/* Set up custom font and form width */
body {
    margin-left: 10px;
    font-family: Arial,sans-serif;
    font-size: small;
}

.quickform {
    min-width: 500px;
    max-width: 600px;
    width: 560px;
}

.separator {
    float: left;
    margin: 0.7em 0 0 0.1em;
}

/* Use default styles included with the package */

<?php 
        if ('@data_dir@' != '@' . 'data_dir@') {
            $filename = '@data_dir@/HTML_QuickForm2/quickform.css';
        } else {
            $filename = dirname(dirname(dirname(__FILE__))) . '/data/quickform.css';
        }
        readfile($filename);
        ?>
    </style>
    <title>HTML_QuickForm2 basic elements example</title>
  </head>
  <body>
<?php 
        $renderer = HTML_QuickForm2_Renderer::factory('default');
        $renderer->setElementTemplateForGroupId('nameGrp', 'html_quickform2_element', '<div class="element<qf:error> error</qf:error>"><qf:error><span class="error">{error}</span><br /></qf:error>{element}<br /><label for="{id}"><qf:required><span class="required">* </span></qf:required>{label}</label></div>');
        $renderer->setTemplateForId('nameGrp', '<div class="row"><p class="label"><qf:required><span class="required">*</span></qf:required><qf:label><label>{label}</label></qf:label></p>{content}</div>');
        echo $form->render($renderer);
        ?>
  </body>
</html>
<?php 
    }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:50,代码来源:wizard.php

示例8: __construct

 public function __construct($id, $values, $action)
 {
     parent::__construct($id);
     $this->naziv = new HTML_QuickForm2_Element_InputText('naziv');
     $this->naziv->setAttribute('size', "100%");
     $this->naziv->setLabel('Naziv:');
     $this->naziv->setValue($values["naziv"]);
     $this->naziv->addRule('required', 'Vnesite naziv.');
     $this->naziv->addRule('regex', 'Pri imenu uporabite le črke, številke, narekovaje ali ločila.', '/^[a-zA-Zšč枊ČĆŽ0-9\'\\"-.,;! ]+$/');
     $this->naziv->addRule('maxlength', 'Ime naj bo krajše od 80 znakov.', 80);
     $this->cena = new HTML_QuickForm2_Element_InputText('cena');
     $this->cena->setAttribute('size', "100%");
     $this->cena->setLabel('Cena:');
     $this->cena->setValue($values["cena"]);
     $this->cena->addRule('required', 'Vnesite ceno.');
     $this->cena->addRule('regex', 'Pri ceni uporabite le številke in piko za decimalne zapise.', '/^[0-9.]+$/');
     $this->cena->addRule('maxlength', 'Cena naj bo krajši od 10 znakov.', 10);
     $this->opis = new HTML_QuickForm2_Element_Textarea('opis');
     $this->opis->setAttribute('rows', 5);
     $this->opis->setAttribute('cols', "98%");
     $this->opis->setLabel('Opis:');
     $this->opis->setValue($values["opis"]);
     $this->opis->addRule('required', 'Vnesite opis.');
     $this->opis->addRule('maxlength', 'Opis naj bo krajši od 250 znakov.', 250);
     if ($action != "profil") {
         $this->aktiven = new HTML_QuickForm2_Element_InputCheckbox('aktiven');
         $this->aktiven->setLabel('Aktiven izdelek:');
         if (isset($values["aktiven"]) && $values["aktiven"] == "da") {
             $this->aktiven->setValue(1);
         }
     }
     $this->gumb = new HTML_QuickForm2_Element_InputSubmit(null);
     if ($action == "dodajanje") {
         $this->gumb->setAttribute('value', 'Ustvari izdelek');
     } elseif ($action == "profil") {
         $this->gumb->setAttribute('value', 'Spremeni');
     } else {
         $this->gumb->setAttribute('value', 'Spremeni izdelek');
     }
     $this->addElement($this->naziv);
     $this->addElement($this->cena);
     $this->addElement($this->opis);
     if ($action != "profil") {
         $this->addElement($this->aktiven);
     }
     $this->addElement($this->gumb);
     $this->addRecursiveFilter('trim');
     $this->addRecursiveFilter('htmlspecialchars');
 }
开发者ID:benjaminovak,项目名称:ep,代码行数:49,代码来源:ProductForm.php

示例9: printForm

function printForm($data = array())
{
    foreach (array('name', 'email', 'copy_me', 'subject', 'text') as $value) {
        if (!isset($data[$value])) {
            $data[$value] = '';
        }
    }
    $form = new HTML_QuickForm2('contect', 'post', array('action' => '/account-mail.php?handle=' . htmlspecialchars($_GET['handle'])));
    $form->removeAttribute('name');
    // Set defaults for the form elements
    $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('name' => htmlspecialchars($data['name']), 'email' => htmlspecialchars($data['email']), 'copy_me' => htmlspecialchars($data['copy_me']), 'subject' => htmlspecialchars($data['subject']), 'text' => htmlspecialchars($data['text']))));
    $form->addElement('text', 'name', array('required' => 'required'))->setLabel('Y<span class="accesskey">o</span>ur Name:', 'size="40" accesskey="o"');
    $form->addElement('email', 'email', array('required' => 'required'))->setLabel('Email Address:');
    $form->addElement('checkbox', 'copy_me')->setLabel('CC me?:');
    $form->addElement('text', 'subject', array('required' => 'required', 'size' => '80'))->setLabel('Subject:');
    $form->addElement('textarea', 'text', array('cols' => 80, 'rows' => 10, 'required' => 'required'))->setLabel('Text:');
    if (!auth_check('pear.dev')) {
        $numeralCaptcha = new Text_CAPTCHA_Numeral();
        $form->addElement('number', 'captcha', array('maxlength' => 4, 'required' => 'required'))->setLabel("What is " . $numeralCaptcha->getOperation() . '?');
        $_SESSION['answer'] = $numeralCaptcha->getAnswer();
    }
    $form->addElement('submit', 'submit')->setLabel('Send Email');
    print $form;
}
开发者ID:stof,项目名称:pearweb,代码行数:24,代码来源:account-mail.php

示例10: testBug20295

 /**
  * If data source contains explicitly provided null values, those should be used
  * @link http://pear.php.net/bugs/bug.php?id=20295
  */
 public function testBug20295()
 {
     $form = new HTML_QuickForm2('bug20295');
     $el = $form->appendChild(new HTML_QuickForm2_ElementImpl('foo'));
     $el->setValue('not empty');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('foo' => null)));
     $this->assertNull($el->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:12,代码来源:ElementTest.php

示例11: _renderRequiredNote

 public static function _renderRequiredNote(HTML_QuickForm2_Renderer $renderer, HTML_QuickForm2 $form)
 {
     if ($renderer->hasRequired && !$form->toggleFrozen(null)) {
         if (($note = $renderer->getOption('required_note')) && !empty($note)) {
             return '<div class="alert alert-info">' . $note . '</div>';
         }
     }
 }
开发者ID:sergiokessler,项目名称:perio,代码行数:8,代码来源:Callback.php

示例12: testBug20295

 /**
  * If defaults contain null values, previous values are reused
  * @link http://pear.php.net/bugs/bug.php?id=20295
  */
 public function testBug20295()
 {
     $form = new HTML_QuickForm2('repeat-bug');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('buggy' => array('name' => array(1 => 'First', 2 => 'Second'), 'extra' => array(1 => 'Has extra', 2 => null)))));
     $group = new HTML_QuickForm2_Container_Group('buggy');
     $group->addText('name');
     $group->addText('extra');
     $repeat = $form->addRepeat(null, array('id' => 'buggy-repeat'), array('prototype' => $group));
     $value = $repeat->getValue();
     $this->assertEquals('', $value['buggy']['extra'][2]);
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:15,代码来源:RepeatTest.php

示例13: HTML_QuickForm2

{
	include('installheader.php');
?>
	<p>Before continuing with the installation, please ensure install/ and includes/ are writable. (<code>chmod -Rv 777 <?=dirname(__FILE__)?> <?=dirname(dirname(__FILE__))?>/includes/</code>)</p>
<?
	include('installfooter.php');
	ob_flush();
	exit(0);
}

if(intval($_GET['page'])==0)
{
	//include('../lib/recaptchalib.php');
	//$recaptchaurl = recaptcha_get_signup_url (null,"FlexCP");
	
	$form = new HTML_QuickForm2('frmInstall');
	$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
	    	'txtSiteURL'		=> 'http://'.$_SERVER['HTTP_HOST'].'/',
	    	'txtSitePath'     	=> dirname(dirname(__FILE__)).'/',
		'txtAdminName'		=> 'Sysop',
		'txtSQLHost'		=> 'localhost',
		'txtSQLPrefix'		=> 'atbbs_',
	)));
	$fsMain = $form->addElement('fieldset')->setLabel('Main ATBBS Configuration');

	$sitename	= $fsMain->addElement('text','txtSiteName',	array(),array('label'=>'BBS\'s Name:'));
	$siteurl	= $fsMain->addElement('text','txtSiteURL',	array(),array('label'=>'Site URL:'));
	$sitepath	= $fsMain->addElement('text','txtSitePath',	array(),array('label'=>'Full path to site folder:'));
	$siteemail	= $fsMain->addElement('text','txtSiteEmail',	array(),array('label'=>'Email shown in automails, in the From: header:'));
	$siteadminname  = $fsMain->addElement('text','txtAdminName',	array(),array('label'=>'Used in place of Anonymous when an admin posts:'));
开发者ID:N3X15,项目名称:ATBBS-Plus,代码行数:30,代码来源:index.php

示例14: testSelectMultipleNoOptionsSelectedOnSubmit

 public function testSelectMultipleNoOptionsSelectedOnSubmit()
 {
     $options = array('1' => 'Option 1', '2' => 'Option 2');
     $formPost = new HTML_QuickForm2('multiple', 'post', null, false);
     $single1 = $formPost->appendChild(new HTML_QuickForm2_Element_Select('single1', null, array('options' => $options)));
     $single2 = $formPost->appendChild(new HTML_QuickForm2_Element_Select('single2', null, array('options' => $options)));
     $multiple = $formPost->appendChild(new HTML_QuickForm2_Element_Select('mult', array('multiple'), array('options' => $options)));
     $this->assertEquals('1', $single1->getValue());
     $this->assertNull($single2->getValue());
     $this->assertNull($multiple->getValue());
     $formPost->addDataSource(new HTML_QuickForm2_DataSource_Array(array('single1' => '2', 'single2' => '2', 'mult' => array('1', '2'))));
     $this->assertEquals('1', $single1->getValue());
     $this->assertEquals('2', $single2->getValue());
     $this->assertNull($multiple->getValue());
     $formGet = new HTML_QuickForm2('multiple2', 'get', null, false);
     $multiple2 = $formGet->appendChild(new HTML_QuickForm2_Element_Select('mult2', array('multiple'), array('options' => $options)));
     $this->assertNull($multiple2->getValue());
     $formGet->addDataSource(new HTML_QuickForm2_DataSource_Array(array('mult2' => array('1', '2'))));
     $this->assertEquals(array('1', '2'), $multiple2->getValue());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:20,代码来源:SelectTest.php

示例15: HTML_Table

    if (count($user_karma) == 0) {
        echo 'No karma yet';
    } else {
        $table = new HTML_Table('style="width: 90%"');
        $table->setCaption('Karma levels for ' . htmlspecialchars($handle), 'style="background-color: #CCCCCC;"');
        $table->addRow(array("Level", "Added by", "Added at", "Remove"), null, 'th');
        foreach ($user_karma as $item) {
            $remove = sprintf("karma.php?action=remove&amp;handle=%s&amp;level=%s", htmlspecialchars($handle), htmlspecialchars($item['level']));
            $table->addRow(array(htmlspecialchars($item['level']), htmlspecialchars($item['granted_by']), htmlspecialchars($item['granted_at']), make_link($remove, make_image("delete.gif"), false, 'onclick="javascript:return confirm(\'Do you really want to remove the karma level ' . htmlspecialchars($item['level']) . '?\');"')));
        }
        echo $table->toHTML();
    }
    echo "<br /><br />";
    $table = new HTML_Table('style="width: 100%"');
    $table->setCaption("Grant karma to " . htmlspecialchars($handle), 'style="background-color: #CCCCCC;"');
    $form = new HTML_QuickForm2('karma_grant', 'post', array('action' => 'karma.php?action=grant'));
    $form->removeAttribute('name');
    $form->addElement('text', 'level')->setLabel('Level:&nbsp;');
    $form->addElement('hidden', 'handle')->setValue(htmlspecialchars($handle));
    $form->addElement('submit', 'submit')->setLabel('Submit Changes');
    $csrf_token_value = create_csrf_token($csrf_token_name);
    $form->addElement('hidden', $csrf_token_name)->setValue($csrf_token_value);
    $table->addRow(array((string) $form));
    echo $table->toHTML();
}
echo "<p>&nbsp;</p><hr />";
$table = new HTML_Table('style="width: 90%"');
$table->setCaption("Karma Statistics", 'style="background-color: #CCCCCC;"');
if (!empty($_GET['a']) && $_GET['a'] == "details" && !empty($_GET['level'])) {
    $table->addRow(array('Handle', 'Granted'), null, 'th');
    foreach ($karma->getUsers($_GET['level']) as $user) {
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:karma.php


注:本文中的HTML_QuickForm2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。