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


PHP HTML_QuickForm2::addDataSource方法代码示例

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


在下文中一共展示了HTML_QuickForm2::addDataSource方法的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: 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

示例5: dirname

<?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 dualselect example: custom element and renderer plugin</title>
</head>
<body>
<?php 
$options = array(4 => "Afghanistan", 8 => "Albania", 12 => "Algeria", 20 => "Andorra", 24 => "Angola", 28 => "Antigua and Barbuda", 32 => "Argentina", 51 => "Armenia", 36 => "Australia", 40 => "Austria", 31 => "Azerbaijan", 44 => "Bahamas", 48 => "Bahrain", 50 => "Bangladesh", 52 => "Barbados", 112 => "Belarus", 56 => "Belgium", 84 => "Belize", 204 => "Benin", 64 => "Bhutan", 68 => "Bolivia", 70 => "Bosnia and Herzegovina", 72 => "Botswana", 76 => "Brazil", 96 => "Brunei Darussalam", 100 => "Bulgaria", 854 => "Burkina Faso", 108 => "Burundi", 116 => "Cambodia", 120 => "Cameroon", 124 => "Canada", 132 => "Cape Verde", 140 => "Central African Republic", 148 => "Chad", 152 => "Chile", 156 => "China", 170 => "Colombia", 174 => "Comoros", 178 => "Congo", 180 => "Congo, Democratic Republic of", 184 => "Cook Islands", 188 => "Costa Rica", 384 => "Cote D'Ivoire", 191 => "Croatia", 192 => "Cuba", 196 => "Cyprus", 203 => "Czech Republic", 208 => "Denmark", 262 => "Djibouti", 212 => "Dominica", 214 => "Dominican Republic", 218 => "Ecuador", 818 => "Egypt", 222 => "El Salvador", 226 => "Equatorial Guinea", 232 => "Eritrea", 233 => "Estonia", 231 => "Ethiopia", 242 => "Fiji", 246 => "Finland", 250 => "France", 266 => "Gabon", 270 => "Gambia", 268 => "Georgia", 276 => "Germany", 288 => "Ghana", 300 => "Greece", 308 => "Grenada", 320 => "Guatemala", 324 => "Guinea", 624 => "Guinea-Bissau", 328 => "Guyana", 332 => "Haiti", 336 => "Holy See (Vatican City State)", 340 => "Honduras", 348 => "Hungary", 352 => "Iceland", 356 => "India", 360 => "Indonesia", 364 => "Iran", 368 => "Iraq", 372 => "Ireland", 376 => "Israel", 380 => "Italy", 388 => "Jamaica", 392 => "Japan", 400 => "Jordan", 398 => "Kazakhstan", 404 => "Kenya", 296 => "Kiribati", 408 => "Korea, Democratic People's Republic of", 410 => "Korea, Republic of", 414 => "Kuwait", 417 => "Kyrgyz Republic", 418 => "Laos", 428 => "Latvia", 422 => "Lebanon", 426 => "Lesotho", 430 => "Liberia", 434 => "Libya", 438 => "Liechtenstein", 440 => "Lithuania", 442 => "Luxembourg", 807 => "Macedonia", 450 => "Madagascar", 454 => "Malawi", 458 => "Malaysia", 462 => "Maldives", 466 => "Mali", 470 => "Malta", 584 => "Marshall Islands", 474 => "Martinique", 478 => "Mauritania", 480 => "Mauritius", 484 => "Mexico", 583 => "Micronesia", 498 => "Moldova", 492 => "Monaco", 496 => "Mongolia", 499 => "Montenegro", 504 => "Morocco", 508 => "Mozambique", 104 => "Myanmar", 516 => "Namibia", 520 => "Nauru", 524 => "Nepal", 528 => "Netherlands", 554 => "New Zealand", 558 => "Nicaragua", 562 => "Niger", 566 => "Nigeria", 570 => "Niue", 578 => "Norway", 512 => "Oman", 586 => "Pakistan", 585 => "Palau", 591 => "Panama", 598 => "Papua New Guinea", 600 => "Paraguay", 604 => "Peru", 608 => "Philippines", 616 => "Poland", 620 => "Portugal", 634 => "Qatar", 642 => "Romania", 643 => "Russian Federation", 646 => "Rwanda", 882 => "Samoa", 674 => "San Marino", 678 => "Sao Tome and Principe", 682 => "Saudi Arabia", 686 => "Senegal", 688 => "Serbia", 690 => "Seychelles", 694 => "Sierra Leone", 702 => "Singapore", 703 => "Slovakia", 705 => "Slovenia", 90 => "Solomon Islands", 706 => "Somalia", 710 => "South Africa", 724 => "Spain", 144 => "Sri Lanka", 659 => "St. Kitts and Nevis", 662 => "St. Lucia", 670 => "St. Vincent and the Grenadines", 736 => "Sudan", 740 => "Suriname", 748 => "Swaziland", 752 => "Sweden", 756 => "Switzerland", 760 => "Syria", 158 => "Taiwan", 762 => "Tajikistan", 834 => "Tanzania", 764 => "Thailand", 626 => "Timor-Leste", 768 => "Togo", 776 => "Tonga", 780 => "Trinidad and Tobago", 788 => "Tunisia", 792 => "Turkey", 795 => "Turkmenistan", 798 => "Tuvalu", 800 => "Uganda", 804 => "Ukraine", 784 => "United Arab Emirates", 826 => "United Kingdom of Great Britain & N. Ireland", 840 => "United States of America", 858 => "Uruguay", 860 => "Uzbekistan", 548 => "Vanuatu", 862 => "Venezuela", 704 => "Viet Nam", 732 => "Western Sahara", 887 => "Yemen", 894 => "Zambia", 716 => "Zimbabwe");
$form = new HTML_QuickForm2('dualselect');
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('destinations' => array(4, 148, 180, 368, 706, 736, 716))));
$fs = $form->addElement('fieldset')->setLabel('A custom "dualselect" element using a renderer plugin for output');
$ds = $fs->addElement('dualselect', 'destinations', array('size' => 10, 'style' => 'width: 215px; font-size: 90%'), array('options' => $options, 'keepSorted' => true, 'from_to' => array('content' => ' &gt;&gt; ', 'attributes' => array('style' => 'font-size: 90%')), 'to_from' => array('content' => ' &lt&lt; ', 'attributes' => array('style' => 'font-size: 90%'))))->setLabel(array('Popular travel destinations:', 'Available', 'Chosen'));
$ds->addRule('required', 'Select at least two destinations', 2, HTML_QuickForm2_Rule::ONBLUR_CLIENT_SERVER);
$fs->addElement('checkbox', 'doFreeze', null, array('content' => 'Freeze dualselect on form submit'));
$fs->addElement('submit', 'testSubmit', array('value' => 'Submit form'));
// outputting form values
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    $value = $form->getValue();
    echo "<pre>\n";
    var_dump($value);
    echo "</pre>\n<hr />";
    if (!empty($value['doFreeze'])) {
        $ds->toggleFrozen(true);
    }
}
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:31,代码来源:dualselect.php

示例6: edit

 /**
  * edit edits the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function edit($cid)
 {
     // check rights
     if (Rights::check_rights($cid, 'calendar')) {
         // smarty-templates
         $sD = new JudoIntranetSmarty();
         // get calendar-object
         $calendar = new Calendar($cid);
         // pagecaption
         $this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#edit') . ": \"{$cid}\" (" . $calendar->get_name() . ")");
         // get rights
         $cRights = $calendar->get_rights()->get_rights();
         // check public access
         $kPublicAccess = array_search(0, $cRights);
         $publicAccess = false;
         if ($kPublicAccess !== false) {
             $publicAccess = true;
             unset($cRights[$kPublicAccess]);
         }
         // prepare return
         $return = '';
         $form = new HTML_QuickForm2('edit_calendar_entry', 'post', array('name' => 'edit_calendar_entry', 'action' => 'calendar.php?id=edit&cid=' . $cid));
         $now_year = (int) date('Y');
         $year_min = $now_year;
         $year_max = $now_year + 3;
         // get datasource
         $datasource = array('date' => $calendar->get_date(), 'name' => $calendar->get_name(), 'shortname' => $calendar->get_shortname(), 'type' => $calendar->return_type(), 'entry_content' => $calendar->get_content(), 'rights' => $cRights);
         // add public access
         if ($publicAccess) {
             $datasource['public'] = 1;
         }
         $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
         // renderer
         $renderer = HTML_QuickForm2_Renderer::factory('default');
         $renderer->setOption('required_note', parent::lang('class.CalendarView#entry#form#requiredNote'));
         // elements
         // date
         $date = $form->addElement('text', 'date', array());
         $date->setLabel(parent::lang('class.CalendarView#entry#form#date') . ':');
         // rule
         $date->addRule('required', parent::lang('class.CalendarView#entry#rule#required.date'));
         $date->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.date'), array($this, 'callback_check_date'));
         // add jquery-datepicker
         // smarty
         $sD->assign('elementid', 'date-0');
         $sD->assign('dateFormat', 'yy-mm-dd');
         $sD->assign('dateValue', $calendar->get_date());
         $this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
         // name
         $name = $form->addElement('text', 'name');
         $name->setLabel(parent::lang('class.CalendarView#entry#form#name') . ':');
         $name->addRule('required', parent::lang('class.CalendarView#entry#rule#required.name'));
         $name->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
         // shortname
         $shortname = $form->addElement('text', 'shortname');
         $shortname->setLabel(parent::lang('class.CalendarView#entry#form#shortname') . ':');
         $shortname->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
         // type
         $options = array_merge(array(0 => '--'), Calendar::return_types());
         $type = $form->addElement('select', 'type');
         $type->setLabel(parent::lang('class.CalendarView#entry#form#type') . ':');
         $type->loadOptions($options);
         $type->addRule('required', parent::lang('class.CalendarView#entry#rule#required.type'));
         $type->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.select'), array($this, 'callback_check_select'));
         // entry_content
         $content = $form->addElement('textarea', 'entry_content');
         $content->setLabel(parent::lang('class.CalendarView#entry#form#entry_content') . ':');
         $content->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
         // select rights
         $options = $_SESSION['user']->return_all_groups('sort');
         $rights = $form->addElement('select', 'rights', array('multiple' => 'multiple', 'size' => 5));
         $rights->setLabel(parent::lang('class.CalendarView#entry#form#rights') . ':');
         $rights->loadOptions($options);
         // checkbox public
         $rights = $form->addElement('checkbox', 'public');
         $rights->setLabel(parent::lang('class.CalendarView#entry#form#public') . ':');
         // submit-button
         $form->addElement('submit', 'submit', array('value' => parent::lang('class.CalendarView#entry#form#submitButton')));
         // validate
         if ($form->validate()) {
             // create calendar-object
             $data = $form->getValue();
             // check $data['rights']
             if (!isset($data['rights'])) {
                 $data['rights'] = array();
             }
             // merge with own groups, add admin
             $data['rights'] = array_merge($data['rights'], $_SESSION['user']->get_groups(), array(1));
             // add public access
             $kPublicAccess = array_search(0, $data['rights']);
             if ($kPublicAccess === false && isset($data['public']) && $data['public'] == 1) {
                 $data['rights'][] = 0;
             } elseif ($kPublicAccess !== false && !isset($data['public'])) {
                 unset($data['rights'][$kPublicAccess]);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.CalendarView.php

示例7: array

    $result->close();
} else {
    // Clear all parameters if a new user will be created.
    $arrayAlbum = array("", "", "", "", "", "", "");
}
/*
 * Create the form with QuickForm2.
 */
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
// Point back to the same page for validation.
$formAction = WS_SITELINK . "?p=edit_alb&id=" . $idAlbum;
// Create a new form object.
$form = new HTML_QuickForm2('album', 'post', array('action' => $formAction), array('name' => 'album'));
// Data source with default values:
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('name' => $arrayAlbum[2], 'description' => $arrayAlbum[3])));
// Album info.
$fsAlbum = $form->addElement('fieldset')->setLabel('Album');
$nameAlbum = $fsAlbum->addElement('text', 'name', array('style' => 'width: 300px;'), array('label' => 'Namn'));
$nameAlbum->addRule('required', 'Fyll i namn på albumet');
$nameAlbum->addRule('maxlength', 'Namnet är för långt för databasen.', 100);
$descriptionAlbum = $fsAlbum->addElement('textarea', 'description', array('style' => 'width: 300px;'), array('label' => 'Beskrivning'));
// Buttons
$buttons = $form->addGroup('buttons')->setSeparator('&nbsp;');
$buttons->addElement('image', 'submitButton', array('src' => 'images/b_enter.gif', 'title' => 'Spara'));
$buttons->addElement('static', 'resetButton')->setContent('<a title="Återställ" href="?p=edit_alb&amp;id=' . $idAlbum . '" ><img src="images/b_undo.gif" alt="Återställ" /></a>');
$buttons->addElement('static', 'cancelButton')->setContent('<a title="Avbryt" href="?p=' . $redirect . '" >
        <img src="images/b_cancel.gif" alt="Avbryt" /></a>');
/*
 * Process the form.
 */
开发者ID:GunnarWinqvist,项目名称:SSKL,代码行数:31,代码来源:PEditAlbum.php

示例8: testBug15708

 public function testBug15708()
 {
     $form = new HTML_QuickForm2('bug15708');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('aRadio' => 1)));
     $aRadio = $form->appendChild(new HTML_QuickForm2_Element_InputCheckable('aRadio'))->setAttribute('value', 1);
     $this->assertContains('checked', $aRadio->__toString());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:7,代码来源:InputCheckableTest.php

示例9: array

while ($row = $st->fetch(PDO::FETCH_ASSOC)) {
    $materia_select[$row['nombre']] = $row['nombre'];
}
*/
$materia_select = $boolean_select;
$form_update = false;
if (isset($record_id)) {
    $form_update = true;
}
$form = new HTML_QuickForm2('form', 'post');
if ($form_update and empty($_POST)) {
    $st = $db->prepare('select * from ' . $params['table'] . ' where ' . $params['primary_key'] . ' = ?');
    $st->execute(array($record_id));
    $edit_row = $st->fetch(PDO::FETCH_ASSOC);
    $defaults['new_row'] = $edit_row;
    $form->addDataSource(new HTML_QuickForm2_DataSource_Array($defaults));
} else {
    // defaults
    $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('new_row' => array('fecha' => time()))));
}
$form->addElement('hidden', 'action')->setValue($params['action']);
$form->addElement('hidden', 'params')->setValue($form_params);
if ($form_update) {
    $form->addElement('text', 'material_id', array('disabled' => 'disabled'), array('label' => 'Material Id'))->setValue($record_id);
}
$form->addElement('select', 'new_row[materia]', array('autofocus' => 'autofocus'))->setLabel(' Materia:')->loadOptions($materia_select)->addRule('required', 'Valor requerido');
$form->addElement('text', 'new_row[titulo]')->setLabel('Titulo:')->addRule('required', 'Valor requerido');
$form->addElement('text', 'new_row[autor]')->setLabel('Autor:')->addRule('required', 'Valor requerido');
$form->addElement('text', 'new_row[cant_hojas]')->setLabel('Cant de hojas:')->addRule('required', 'Valor requerido');
$form->addElement('text', 'new_row[carpeta]')->setLabel('Carpeta:')->addRule('required', 'Valor requerido');
$form->addElement('text', 'new_row[folio]')->setLabel('Folio:')->addRule('required', 'Valor requerido');
开发者ID:sergiokessler,项目名称:perio,代码行数:31,代码来源:material_form.php

示例10: get_form_html

 /**
  * Get form rendered as html
  *
  * @param array $return  form parameters
  * @return string
  *
  * @access private
  */
 private function get_form_html($return)
 {
     // returns html based on form parameters in $return
     $out = "<p>" . $return['introduction'] . "</p>" . "\r\n";
     $form = new HTML_QuickForm2($return['name'], $return['method'], $return['action']);
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($return['values']));
     if (count($return['parameters']) > 0) {
         $fieldset = $form->addElement('fieldset');
         foreach (array_keys($return['parameters']) as $key) {
             if (!in_array($key, $return['exclude'])) {
                 $parameter = $return['parameters'][$key];
                 $valid_option = array();
                 if (array_key_exists($key, $return['valid_options'])) {
                     $valid_option = $return['valid_options'][$key];
                     if ('number' == $valid_option['type']) {
                         $input_type = 'text';
                     }
                     if ('boolean' == $valid_option['type']) {
                         $input_type = 'checkbox';
                     }
                 }
                 $value = '';
                 $fieldset->addElement($input_type, $key)->setLabel($parameter['label']);
             }
         }
     }
     if (count($return['hidden']) > 0) {
         $fieldset_hidden = $form->addElement('fieldset');
         foreach (array_keys($return['hidden']) as $key) {
             $value = $return['hidden'][$key];
             $fieldset_hidden->addElement('hidden', $key)->setValue($value);
         }
     }
     // add page_id
     $fieldset->addElement('hidden', 'request')->setValue($return['request']);
     $fieldset->addElement('hidden', 'page_id')->setValue($_GET['page_id']);
     $fieldset->addElement('submit', null, array('value' => $return['submit']));
     $out .= $form;
     return $out;
 }
开发者ID:WillSwales,项目名称:financial-maths-mediawiki,代码行数:48,代码来源:class-ct1-render.php

示例11: die

 */
if (!isset($nextPage)) {
    die('Direct access to the page is not allowed.');
}
/*
 * Generera formuläret med QuickForm2.
 */
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
// Alternativ för nationalitet.
$options = array('--' => '--', 'se' => 'Svensk', 'no' => 'Norsk', 'dk' => 'Dansk', 'fi' => 'Finsk', 'nn' => 'Annan');
$formAction = WS_SITELINK . "?p=appl";
// Pekar tillbaka på samma sida igen.
$form = new HTML_QuickForm2('application', 'post', array('action' => $formAction), array('name' => 'application'));
// data source with default values:
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('personnummerElev' => 'ååååmmdd-nnnn', 'stadsdelBostad' => 'Mont Kiara, Ampang, ...', 'stadBostad' => 'Kuala Lumpur', 'statBostad' => 'Kuala Lumpur, Selangor, ...', 'skolaElev' => 'MKIS, ISKL, ...')));
// Data för eleven
$fsElev = $form->addElement('fieldset')->setLabel('Eleven');
$fornamnPerson = $fsElev->addElement('text', 'fornamnPerson', array('style' => 'width: 300px;'), array('label' => 'Förnamn:'));
$fornamnPerson->addRule('required', 'Fyll i elevens förnamn');
$fornamnPerson->addRule('maxlength', 'Elevens förnamn får max vara 50 tecken.', 50);
$efteramnPerson = $fsElev->addElement('text', 'efternamnPerson', array('style' => 'width: 300px;'), array('label' => 'Efternamn:'));
$efteramnPerson->addRule('required', 'Fyll i elevens efternamn');
$efteramnPerson->addRule('maxlength', 'Elevens efternamn får max vara 50 tecken.', 50);
$nationalitetElev = $fsElev->addElement('select', 'nationalitetElev', null, array('options' => $options, 'label' => 'Nationalitet:'));
$personnummerElev = $fsElev->addElement('text', 'personnummerElev', array('style' => 'width: 300px;'), array('label' => 'Personnummer:'));
$personnummerElev->addRule('required', 'Fyll i elevens personnummer eller födelsedatum.');
$personnummerElev->addRule('regex', 'Personnumret måste ha formen ååååmmdd-nnnn. Födelsedatum formen ååååmmdd.', '/^(19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])(-\\d{4})?$/');
$kommentar = $fsElev->addElement('static', 'comment')->setContent('Fyll i svenskt personnummer om eleven har det, annars 
    födelsedatum.');
$arskursElev = $fsElev->addElement('text', 'arskursElev', array('style' => 'width: 300px;'), array('label' => 'Årskurs i ordinarie skola:'));
开发者ID:GunnarWinqvist,项目名称:SSKL,代码行数:31,代码来源:PApplication.php

示例12: testSetDataSources

 public function testSetDataSources()
 {
     $ds1 = new HTML_QuickForm2_DataSource_Array(array('key' => 'value'));
     $ds2 = new HTML_QuickForm2_DataSource_Array(array('another key' => 'foo'));
     $form = new HTML_QuickForm2('dstest');
     $this->assertEquals(0, count($form->getDataSources()));
     $form->addDataSource($ds2);
     $this->assertEquals(1, count($form->getDataSources()));
     $form->setDataSources(array($ds1, $ds2));
     $this->assertEquals(2, count($form->getDataSources()));
     try {
         $form->setDataSources(array($ds1, 'bogus', $ds2));
     } catch (HTML_QuickForm2_InvalidArgumentException $e) {
         return;
     }
     $this->fail('Expected HTML_QuickForm2_InvalidArgumentException was not thrown');
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:17,代码来源:QuickForm2Test.php

示例13: 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

示例14: characters

<p>
 Note that this account can also be used to report a bug or comment on an existing bug.
</p>

<p>
Please use the &quot;latin counterparts&quot; of non-latin characters (for instance th instead of &thorn;).
</p>

MSG;
    echo '<a name="requestform" id="requestform"></a>';
    report_error($errors);
    $form = new HTML_QuickForm2('account-request-vote', 'post', array('action' => 'account-request-vote.php#requestform'));
    $form->removeAttribute('name');
    $renderer = new HTML_QuickForm2_Renderer_PEAR();
    $hsc = array_map('htmlspecialchars', $stripped);
    // Set defaults for the form elements
    $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('handle' => @$hsc['handle'], 'firstname' => @$hsc['firstname'], 'lastname' => @$hsc['lastname'], 'email' => @$hsc['email'], 'showemail' => @$hsc['showemail'], 'read_everything' => @$hsc['read_everything'])));
    $form->addElement('text', 'handle', array('placeholder' => 'psmith', 'maxlength' => "20", 'accesskey' => "r", 'required' => 'required'))->setLabel('Use<span class="accesskey">r</span>name:');
    $form->addElement('text', 'firstname', array('placeholder' => 'Peter', 'required' => 'required'))->setLabel('First Name:');
    $form->addElement('text', 'lastname', array('placeholder' => 'Smith', 'required' => 'required'))->setLabel('Last Name:');
    $form->addElement('password', 'password', array('size' => 10, 'required' => 'required'))->setLabel('Password:');
    $form->addElement('password', 'password2', array('size' => 10, 'required' => 'required'))->setLabel('Repeat Password:');
    $form->addElement('number', 'captcha', array('maxlength' => 4, 'required' => 'required'))->setLabel("What is " . $numeralCaptcha->getOperation() . '?');
    $_SESSION['answer'] = $numeralCaptcha->getAnswer();
    $form->addElement('email', 'email', array('placeholder' => 'you@example.com', 'required' => 'required'))->setLabel('Email Address:');
    $form->addElement('checkbox', 'showemail')->setLabel('Show email address?');
    $form->addGroup('read_everything')->addElement('checkbox', 'comments_read', array('required' => 'required'))->setLabel('I have read EVERYTHING on this page');
    $form->addElement('submit', 'submit')->setLabel('Submit Request');
    print $form->render($renderer);
}
response_footer();
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:account-request-vote.php

示例15: testCheckboxUncheckedOnSubmit

 public function testCheckboxUncheckedOnSubmit()
 {
     $formPost = new HTML_QuickForm2('boxed', 'post', null, false);
     $box1 = $formPost->appendChild(new HTML_QuickForm2_Element_InputCheckbox('box1'));
     $box2 = $formPost->appendChild(new HTML_QuickForm2_Element_InputCheckbox('box2'));
     $this->assertEquals('1', $box1->getValue());
     $this->assertNull($box2->getValue());
     $formPost->addDataSource(new HTML_QuickForm2_DataSource_Array(array('box2' => '1')));
     $this->assertEquals('1', $box1->getValue());
     $this->assertNull($box2->getValue());
     $formGet = new HTML_QuickForm2('boxed2', 'get', null, false);
     $box3 = $formGet->appendChild(new HTML_QuickForm2_Element_InputCheckbox('box3'));
     $this->assertNull($box3->getValue());
     $formGet->addDataSource(new HTML_QuickForm2_DataSource_Array(array('box3' => '1')));
     $this->assertEquals('1', $box3->getValue());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:16,代码来源:InputCheckboxTest.php


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