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


PHP HTML_QuickForm2::getValue方法代码示例

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


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

示例1: storeValues

 /**
  * Stores the form values (and validation status) is session container
  *
  * @param    bool    Whether to store validation status
  */
 public function storeValues($validate = true)
 {
     $this->populateFormOnce();
     $container = $this->getController()->getSessionContainer();
     $id = $this->form->getId();
     $container->storeValues($id, (array) $this->form->getValue());
     if ($validate) {
         $container->storeValidationStatus($id, $this->form->validate());
     }
     return $container->getValidationStatus($id);
 }
开发者ID:N3X15,项目名称:ATBBS-Plus,代码行数:16,代码来源:Page.php

示例2: array

$ePostMalsman->addRule('required', 'Fyll i målsmans e-postadress');
$ePostMalsman->addRule('regex', 'Det är inte en korrekt e-postadress.', "/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\$/");
$ePostMalsman->addRule('maxlength', 'E-postadressen får max vara 50 tecken.', 50);
// Sändknappen
$submitButton = $form->addElement('submit', 'submit', array('value' => 'Skicka'));
// Tar bort 'space' först och sist på alla värden.
$form->addRecursiveFilter('trim');
$mainTextHTML = "";
if ($form->validate()) {
    //Om sidan är riktigt ifylld.
    $mainTextHTML .= "<h2>Din information har skickats till Svenska \n        Skolföreningen. Tack för din anmälan!</h2>";
    $eMailAdr = "registrering@svenskaskolankualalumpur.com";
    $subject = "Ny anmälan till SSKL";
    $headers = WS_MAILHEADERS;
    $text = "Ny anmälan till Svenska Skolföreningen i Kuala Lumpur. \n";
    foreach ($form->getValue() as $parameter => $value) {
        $text .= $parameter . "\t" . $value . "\n";
    }
    mail($eMailAdr, $subject, $text, $headers);
    $form->removeChild($submitButton);
    // Tag bort sänd-knappen.
    $form->removeChild($kommentar);
    // Tag bort kommentarer.
    $form->toggleFrozen(true);
    // Frys formuläret inför ny visning.
    if ($debugEnable) {
        $debug .= "eMailAdr=" . $eMailAdr . " subject=" . $subject . "text=" . $text . " headers=" . $headers . "<br />\r\n";
    }
}
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'errors_prefix' => 'Följand information saknas eller är felaktigt 
            ifylld:', 'errors_suffix' => '', 'required_note' => 'Obligatoriska fält är markerade med en 
开发者ID:GunnarWinqvist,项目名称:SSKL,代码行数:31,代码来源:PApplication.php

示例3: picture

// and old password shuld be given
$newPassword->addRule('empty')->and_($repPassword->addRule('empty'))->or_($newPassword->createRule('eq', 'The passwords do not match', $repPassword))->and_($newPassword->createRule('minlength', 'The password is too short', 6))->and_($oldPassword->createRule('nonempty', 'Supply old password if you want to change it'));
//
// File uploads validation
//
$fsUpload = $form->addElement('fieldset')->setLabel('Upload picture (try one &gt; 100 kB for fun)');
$upload = $fsUpload->addElement('file', 'testUpload', array('style' => 'width: 200px'))->setLabel('Picture (gif, jpg, png, &lt;=20kB):');
// no longer using special 'uploadedfile' rule for uploads
$upload->addRule('required', 'Please upload picture');
// no longer using 'filename' rule for uploads
$upload->addRule('regex', 'Allowed extensions: .gif, .jp(e)g, .png', '/\\.(gif|jpe?g|png)$/i');
$upload->addRule('mimetype', 'Your browser doesn\'t think that\'s an image', array('image/gif', 'image/png', 'image/jpeg', 'image/pjpeg'));
$upload->addRule('maxfilesize', 'File is too big, allowed size 20kB', 20480);
$form->addElement('submit', 'testSubmit', array('value' => 'Send'));
if ($form->validate()) {
    echo "<pre>\n";
    var_dump($form->getValue());
    echo "</pre>\n<hr />";
    $form->toggleFrozen(true);
}
echo '<form' . $form->getAttributes(true) . ">\n";
foreach ($form as $element) {
    output_element($element);
}
?>

</form>

  </body>

</html>
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:31,代码来源:builtin-rules.php

示例4: array

// 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.
 */
// Remove 'space' first and last in all parameters.
$form->addRecursiveFilter('trim');
$mainTextHTML = "";
//If the page is correct filled in the update the DB.
if ($form->validate()) {
    //Wash the input.
    $formValues = $form->getValue();
    $nameAlbum = $dbAccess->WashParameter(strip_tags($formValues['name']));
    $descriptionAlbum = $dbAccess->WashParameter(strip_tags($formValues['description']));
    $presentTime = time();
    if ($idAlbum) {
        // If $idAlbum already exists, update the DB.
        $timeEditedAlbum = $presentTime;
        $query = "\n            UPDATE {$tableAlbum} SET \n                nameAlbum        = '{$nameAlbum}',\n                descriptionAlbum = '{$descriptionAlbum}',\n                timeEditedAlbum  = '{$timeEditedAlbum}'\n                WHERE idAlbum = '{$idAlbum}';\n        ";
        $dbAccess->SingleQuery($query);
    } else {
        // Otherwise a new album is added to the DB.
        $album_idUser = $_SESSION['idUser'];
        $timeCreatedAlbum = $presentTime;
        $timeEditedAlbum = $presentTime;
        $query = "\n            INSERT INTO {$tableAlbum} (\n                album_idUser, \n                nameAlbum, \n                descriptionAlbum, \n                timeCreatedAlbum,\n                timeEditedAlbum)\n            VALUES (\n                '{$album_idUser}', \n                '{$nameAlbum}',\n                '{$descriptionAlbum}',\n                '{$timeCreatedAlbum}',\n                '{$timeEditedAlbum}'\n                );\n        ";
        $dbAccess->SingleQuery($query);
开发者ID:GunnarWinqvist,项目名称:SSKL,代码行数:31,代码来源:PEditAlbum.php

示例5: read_preset_form

 /**
  * read_preset_form generates a quickform-object to choose the announcement-preset,
  * if validated redirect to announcement.php?id=new&cid=$id
  * 
  * @param object $calendar the actual calendarentry
  * @return object quickform-object to choose the preset, if validated redirect to new announcement
  */
 private function read_preset_form(&$calendar)
 {
     // check sort or from/to
     $sort = $from = $to = '';
     if ($this->get('sort') !== false) {
         $sort = "&sort=" . $this->get('sort');
     }
     if ($this->get('from') !== false) {
         $from = "&from=" . $this->get('from');
     }
     if ($this->get('to') !== false) {
         $to = "&to=" . $this->get('to');
     }
     // form-object
     $form = new HTML_QuickForm2('choose_preset_' . $calendar->get_id(), 'post', array('name' => 'choose_preset_' . $calendar->get_id(), 'action' => 'calendar.php?id=listall' . $sort . $from . $to));
     // add selectfield
     $select = $form->addSelect('preset', array());
     $options = array(0 => parent::lang('class.CalendarView#read_preset_form#select#choosePreset'));
     $options = $options + Preset::read_all_presets('calendar');
     $select->loadOptions($options);
     $select->addRule('callback', parent::lang('class.CalendarView#read_preset_form#rule#select'), array($this, 'callback_check_select'));
     // add submit
     $submit = $form->addSubmit('submit', array('value' => parent::lang('class.CalendarView#read_preset_form#select#submit')));
     // validate
     if ($form->validate()) {
         // get data
         $data = $form->getValue();
         // insert preset_id in calendar-entry
         $update = array('preset_id' => $data['preset']);
         $calendar->update($update);
         $calendar->write_db('update');
         // redirect to listall
         header('Location: calendar.php?id=listall' . $sort . $from . $to);
         exit;
     } else {
         return $form;
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:45,代码来源:class.CalendarView.php

示例6: edit

 /**
  * edit edits the entry
  * 
  * @return string html-string
  */
 private function edit()
 {
     // smarty-templates
     $sD = new JudoIntranetSmarty();
     // check rights
     if (Rights::check_rights($this->get('cid'), 'calendar')) {
         // check cid and pid given
         if ($this->get('cid') !== false && $this->get('pid') !== false) {
             // check cid and pid exists
             if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
                 // pagecaption
                 $this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#edit'));
                 // prepare return
                 $return = '';
                 // get preset
                 $preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
                 // get fields
                 $fields = $preset->get_fields();
                 // formular
                 $form = new HTML_QuickForm2('edit_announcement', 'post', array('name' => 'edit_announcement', 'action' => 'announcement.php?id=edit&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
                 // values
                 $datasource = array();
                 foreach ($fields as $field) {
                     // read values
                     $field->read_value();
                     // check type
                     if ($field->get_type() == 'text') {
                         // check defaults
                         $datasource['calendar-' . $field->get_id()]['manual'] = '';
                         $datasource['calendar-' . $field->get_id()]['defaults'] = 0;
                         if ($field->get_value() == '') {
                             $datasource['calendar-' . $field->get_id()]['defaults'] = 'd' . $field->get_defaults();
                         } else {
                             $datasource['calendar-' . $field->get_id()]['manual'] = $field->get_value();
                         }
                     } elseif ($field->get_type() == 'dbhierselect') {
                         // explode value
                         list($v_first, $v_second) = explode('|', $field->get_value(), 2);
                         // set values
                         $datasource['calendar-' . $field->get_id()][0] = $v_first;
                         $datasource['calendar-' . $field->get_id()][1] = $v_second;
                     } elseif ($field->get_type() == 'dbselect') {
                         // check multiple
                         if (strpos($field->get_value(), '|') !== false) {
                             // separate value
                             $values = explode('|', $field->get_value());
                             foreach ($values as $i => $value) {
                                 $datasource['calendar-' . $field->get_id()][$i] = $value;
                             }
                         } else {
                             $datasource['calendar-' . $field->get_id()] = $field->get_value();
                         }
                     } else {
                         $datasource['calendar-' . $field->get_id()] = $field->get_value();
                     }
                 }
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
                 // renderer
                 $renderer = HTML_QuickForm2_Renderer::factory('default');
                 $renderer->setOption('required_note', parent::lang('class.AnnouncementView#entry#form#requiredNote'));
                 // generate field-quickform and add to form
                 foreach ($fields as $field) {
                     // generate quickform
                     $field_id = $field->read_quickform(array(), true);
                     // check $field_id
                     if ($field_id != '' && $field->get_type() == 'date') {
                         // smarty
                         $sD->assign('elementid', $field_id . '-0');
                         $sD->assign('dateFormat', 'yy-mm-dd');
                         $sD->assign('dateValue', $field->get_value());
                         $this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
                     }
                     // add to form
                     $form->appendChild($field->get_quickform());
                 }
                 // submit-button
                 $form->addSubmit('submit', array('value' => parent::lang('class.AnnouncementView#edit#form#submitButton')));
                 // validate
                 if ($form->validate()) {
                     // get calendar
                     $calendar = new Calendar($this->get('cid'));
                     // prepare marker-array
                     $announcement = array('version' => date('dmy'));
                     // get data
                     $data = $form->getValue();
                     // insert values
                     foreach ($fields as $field) {
                         // values to db
                         $field->value($data[$field->get_table() . '-' . $field->get_id()]);
                         $field->write_db('update');
                     }
                     // add calendar-fields to array
                     $calendar->add_marks($announcement);
                     // add field-names and -values to array
                     $preset->add_marks($announcement);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.AnnouncementView.php

示例7: correct

 /**
  * correct handles the corrections of the protocol
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the correction page
  */
 private function correct($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#correct'));
     // get protocol object
     $protocol = new Protocol($pid);
     $correctable = $protocol->get_correctable(false);
     // js tiny_mce
     $tmce = array('element' => 'protocol-0', 'css' => 'templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css', 'transitem' => parent::lang('class.ProtocolView#new_entry#tmce#item'), 'transdecision' => parent::lang('class.ProtocolView#new_entry#tmce#decision'));
     // smarty
     $this->tpl->assign('tmce', $tmce);
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) && (in_array($_SESSION['user']->get_id(), $correctable['correctors']) || $_SESSION['user']->get_userinfo('name') == $protocol->get_owner())) {
         // check owner
         if ($_SESSION['user']->get_userinfo('name') == $protocol->get_owner()) {
             // smarty
             $sPCo = new JudoIntranetSmarty();
             // check action
             if ($this->get('action') == 'diff' && $this->get('uid') !== false) {
                 // diff correction of $uid
                 // get correction
                 $correction = new ProtocolCorrection($protocol, $this->get('uid'));
                 // clean protocols for diff
                 $diffBase = html_entity_decode(preg_replace('/<.*>/U', '', $protocol->get_protocol()));
                 $diffNew = html_entity_decode(preg_replace('/<.*>/U', '', $correction->get_protocol()));
                 // smarty
                 $sJsDL = new JudoIntranetSmarty();
                 // activate difflib js-files
                 $this->tpl->assign('jsdifflib', true);
                 // set values for difflib
                 $difflib = array('protDiffBase' => 'protDiffBase-0', 'protDiffNew' => 'protDiffNew-0', 'protDiffOut' => 'diffOut', 'protDiffBaseCaption' => parent::lang('class.ProtocolView#correct#diff#baseCaption'), 'protDiffNewCaption' => parent::lang('class.ProtocolView#correct#diff#newCaption'));
                 // add difflib values to js-template
                 $sJsDL->assign('dl', $difflib);
                 $this->add_jquery($sJsDL->fetch('smarty.js-jsdifflib.tpl'));
                 // add diffOut to template
                 $sPCo->assign('diffOut', 'diffOut');
                 // build form
                 $form = new HTML_QuickForm2('diffCorrection', 'post', array('name' => 'diffCorrection', 'action' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid')));
                 $datasource = array('protocol' => $protocol->get_protocol(), 'protDiffBase' => $diffBase, 'protDiffNew' => $diffNew);
                 // add datasource
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
                 // renderer
                 $renderer = HTML_QuickForm2_Renderer::factory('default');
                 $renderer->setOption('required_note', parent::lang('class.ProtocolView#entry#form#requiredNote'));
                 // elements
                 // protocol text
                 $protocolTA = $form->addElement('textarea', 'protocol');
                 $protocolTA->setLabel(parent::lang('class.ProtocolView#entry#form#protocol') . ':');
                 $protocolTA->addRule('regex', parent::lang('class.ProtocolView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                 // checkbox to mark correction as finished
                 $finished = $form->addElement('checkbox', 'finished');
                 $finished->setLabel(parent::lang('class.ProtocolView#entry#form#finished') . ':');
                 // hidden textareas for texts to diff
                 $protocolBase = $form->addElement('textarea', 'protDiffBase');
                 $protocolNew = $form->addElement('textarea', 'protDiffNew');
                 // submit-button
                 $form->addElement('submit', 'submit', array('value' => parent::lang('class.ProtocolView#entry#form#submitButton')));
                 // add form to template
                 $sPCo->assign('c', true);
                 $sPCo->assign('form', $form->render($renderer));
                 // validate
                 if ($form->validate()) {
                     // get form data
                     $data = $form->getValue();
                     // check finished
                     if (!isset($data['finished'])) {
                         $data['finished'] = 0;
                     }
                     $correctionUpdate = array('finished' => $data['finished']);
                     $protocolUpdate = array('protocol' => $data['protocol']);
                     // update
                     $protocol->update($protocolUpdate);
                     $correction->update($correctionUpdate);
                     $protocol->writeDb('update');
                     $correction->writeDb('update');
                     // message
                     $message = array('message' => parent::lang('class.ProtocolView#correct#message#corrected'), 'href' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid'), 'title' => parent::lang('class.ProtocolView#correct#message#back'), 'text' => parent::lang('class.ProtocolView#correct#message#back'));
                     // assign to template
                     $sPCo->assign('c', false);
                     $sPCo->assign('message', $message);
                 }
             } else {
                 // list all corrections
                 // get corrections
                 $corrections = ProtocolCorrection::listCorrections($pid);
                 // put information together
                 $list = array();
                 $user = new User();
                 foreach ($corrections as $correction) {
                     // change user
                     $user->change_user($correction['uid'], false, 'id');
                     // fill list
                     $img = false;
                     if ($correction['finished'] == 1) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.ProtocolView.php

示例8: array

?>
    </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);
    }
}
$renderer = HTML_QuickForm2_Renderer::factory('default');
$form->render($renderer);
echo $renderer->getJavascriptBuilder()->getLibraries(true, true);
echo $renderer;
?>
</body>
</html>
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:31,代码来源:dualselect.php

示例9: testRequest19403

 /**
  * Do not return values for automatically added elements from getValue()
  * @link http://pear.php.net/bugs/bug.php?id=19403
  */
 public function testRequest19403()
 {
     $_POST = array('_qf__track' => '');
     $form = new HTML_QuickForm2('track');
     $this->assertArrayHasKey('_qf__track', $form->getRawValue());
     $this->assertArrayNotHasKey('_qf__track', $form->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:11,代码来源:QuickForm2Test.php

示例10: take

 /**
  * take creates the form to take an inventoryitem from somebody else
  * 
  * @param int $did entry-id for the inventoryitem
  * @return string html-string with the form
  */
 private function take($did)
 {
     // check rights
     if (Rights::check_rights($did, 'inventory')) {
         // pagecaption
         $this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#take'));
         // get db-object
         $db = Db::newDb();
         // get inventory-object
         $inventory = new Inventory($did);
         // check owned
         if ($inventory->get_owned() == 'given') {
             // smarty-template
             $sT = new JudoIntranetSmarty();
             // prepare return
             $return = '';
             // get preset
             $preset = $inventory->get_preset();
             // get fields
             $fields = $preset->get_fields();
             // add headline
             $sT->assign('caption', parent::lang('class.InventoryView#take#page#headline') . ': ' . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
             // add take from
             $movements = Inventory::movement_last_row($db, $inventory->get_id(), 'user_id', 2);
             $user = new User();
             $user->change_user($movements[1], false, 'id');
             $sT->assign('takefrom', parent::lang('class.InventoryView#take#page#TakeFrom') . ': ' . $user->get_userinfo('name'));
             // add accessory info
             $sT->assign('accessoryinfo', parent::lang('class.InventoryView#take#page#accessory.required'));
             // formular
             $form = new HTML_QuickForm2('inventory_take', 'post', array('name' => 'inventory_take', 'action' => 'inventory.php?id=take&did=' . $this->get('did')));
             // renderer
             $renderer = HTML_QuickForm2_Renderer::factory('default');
             $renderer->setOption('required_note', parent::lang('class.InventoryView#entry#form#requiredNote'));
             // generate field-quickform and add to form
             foreach ($fields as $field) {
                 // check if given
                 if ($inventory->movement_last_accessories($field) === true || $field->get_type() == 'text') {
                     // generate quickform
                     $field->read_quickform();
                 } else {
                     // generate quickform
                     $field->read_quickform(array('disabled' => 'disabled'));
                 }
                 // add to form
                 $form->appendChild($field->get_quickform());
             }
             // submit-button
             $form->addSubmit('submit', array('value' => parent::lang('class.InventoryView#take#form#submitButton')));
             // validate
             if ($form->validate()) {
                 // values
                 $values = $form->getValue();
                 // write to db
                 $insert_id = $this->movement_to_db('taken', $inventory->get_id(), $_SESSION['user']->userid());
                 // accessory to db
                 $this->values_to_db($insert_id, $fields, $values);
                 // headline
                 $sT->assign('action', $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ') ' . parent::lang('class.InventoryView#take#page#headline.taken'));
                 // accessory
                 $sT->assign('accessoryaction', parent::lang('class.InventoryView#take#page#accessory.taken'));
                 // walk through fields
                 $data = array();
                 foreach ($fields as $field) {
                     // check value
                     if (isset($values['inventory-' . $field->get_id()])) {
                         $field_value = $values['inventory-' . $field->get_id()];
                     } else {
                         $field_value = 0;
                     }
                     // return field and value as HTML
                     $field->value($field_value);
                     $data[] = $field->value_to_html();
                 }
                 $sT->assign('form', '');
                 $sT->assign('data', $data);
             } else {
                 $sT->assign('form', $form->render($renderer));
             }
             // return
             return $sT->fetch('smarty.inventory.takegive.tpl');
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('NotGivenTo', $this->get('id'), $did);
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $did);
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:100,代码来源:class.InventoryView.php

示例11: array

$fsCustom->addElement('date', 'testDate', null, array('format' => 'd-F-Y', 'minYear' => date('Y'), 'maxYear' => 2001))->setLabel('Today is:');
$fsCustom->addElement('hierselect', 'testHierselect', array('style' => 'width: 20em;'))->setLabel('Hierarchical select:')->loadOptions(array($main, $secondary))->setSeparator('<br />');
// buttons
$fsButton = $form->addElement('fieldset')->setLabel('Buttons');
$testReset = $fsButton->addElement('reset', 'testReset', array('value' => 'This is a reset button'));
$fsButton->addElement('inputbutton', 'testInputButton', array('value' => 'Click this button', 'onclick' => "alert('This is a test.');"));
$fsButton->addElement('button', 'testButton', array('onclick' => "alert('Almost nothing');", 'type' => 'button'), array('content' => '<img src="http://pear.php.net/gifs/pear-icon.gif" ' . 'width="32" height="32" alt="pear" />This button does almost nothing'));
// submit buttons in nested fieldset
$fsSubmit = $fsButton->addElement('fieldset')->setLabel('These buttons can submit the form');
$fsSubmit->addElement('submit', 'testSubmit', array('value' => 'Test Submit'));
$fsSubmit->addElement('button', 'testSubmitButton', array('type' => 'submit'), array('content' => '<img src="http://pear.php.net/gifs/pear-icon.gif" ' . 'width="32" height="32" alt="pear" />This button submits'));
$fsSubmit->addElement('image', 'testImage', array('src' => 'http://pear.php.net/gifs/pear-icon.gif'));
$context = array();
// outputting form values
if ($form->validate()) {
    $context['submitvalues'] = print_r($form->getValue(), true);
    // let's freeze the form and remove the reset button
    $fsButton->removeChild($testReset);
    $form->toggleFrozen(true);
}
if ('@data_dir@' != '@' . 'data_dir@') {
    $filename = '@data_dir@/HTML_QuickForm2/quickform.css';
} else {
    $filename = dirname(dirname(dirname(dirname(__FILE__)))) . '/data/quickform.css';
}
$context['default_styles'] = file_get_contents($filename);
$renderer = HTML_QuickForm2_Renderer::factory('array');
$form->render($renderer);
$loader = new Twig_Loader_Filesystem(dirname(__FILE__) . '/templates');
// in real life usage you should set up the cache directory!
$twig = new Twig_Environment($loader);
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:31,代码来源:array-twig.php

示例12: testGetValue

 public function testGetValue()
 {
     $value1 = array('foo' => 'foo value');
     $value2 = array('bar' => 'bar value', 'baz' => array('quux' => 'baz value'));
     $valueAnon = array('e1' => 'e1 value');
     $formValue = array('g1' => $value1, 'g2' => array('i2' => $value2)) + $valueAnon;
     $form = new HTML_QuickForm2('testGroupGetValue');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($formValue));
     $g1 = $form->addElement('group', 'g1');
     $g1->addElement('text', 'foo');
     $g2 = $form->addElement('group', 'g2[i2]');
     $g2->addElement('text', 'bar');
     $g2->addElement('text', 'baz[quux]');
     $anon = $form->addElement('group');
     $anon->addElement('text', 'e1');
     $this->assertEquals($formValue, $form->getValue());
     $this->assertEquals($value1, $g1->getValue());
     $this->assertEquals($value2, $g2->getValue());
     $this->assertEquals($valueAnon, $anon->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:20,代码来源:GroupTest.php

示例13: new_row


//.........这里部分代码省略.........
         // check id
         if ($col->name != 'id') {
             // col->type
             // 252 = text, 253 = varchar; 1 = tinyint(boolean); 3 = int
             // add field
             $field = null;
             // check category
             if ($col->name == 'category') {
                 // get options
                 $cat_sql = "SELECT id,name FROM category WHERE valid=1";
                 $cat_result = $db->query($cat_sql);
                 $options = array('--');
                 while (list($id, $name) = $cat_result->fetch_array(MYSQL_NUM)) {
                     $options[$id] = $name;
                 }
                 // select
                 $field = $form->addElement('select', $col->name, array());
                 $field->setLabel($translated_col . ':');
                 // load options
                 $field->loadOptions($options);
                 // add rules
                 if ($table == 'defaults') {
                     $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#requiredSelect'));
                     $field->addRule('callback', parent::lang('class.AdministrationView#new_row#rule#checkSelect'), array($this, 'callback_check_select'));
                 }
             } else {
                 // check type
                 if ($col->type == 252) {
                     // textarea
                     $field = $form->addElement('textarea', $col->name, array());
                     $field->setLabel($translated_col . ':');
                     // add rules
                     $field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                     // required
                     if ($table == 'defaults') {
                         $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
                     }
                 } elseif ($col->type == 253 || $col->type == 3) {
                     // input
                     $field = $form->addElement('text', $col->name, array());
                     $field->setLabel($translated_col . ':');
                     // add rules
                     $field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                     // required
                     if ($table == 'defaults') {
                         $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
                     }
                 } elseif ($col->type == 1) {
                     // input
                     $field = $form->addElement('checkbox', $col->name, array());
                     $field->setLabel($translated_col . ':');
                 }
             }
         }
         // increment field-counter
         $i++;
     }
     // submit-button
     $form->addSubmit('submit', array('value' => parent::lang('class.AdministrationView#new_row#form#submitButton')));
     // validate
     if ($form->validate()) {
         // set output
         $return .= $this->p('class="edit_caption"', parent::lang('class.AdministrationView#new_row#caption#done'));
         // get data
         $data = $form->getValue();
         // prepare statement
         $sql = "INSERT INTO {$table} ";
         $sql_field = "(id,";
         $sql_value = " VALUES (NULL,";
         foreach ($data as $field => $value) {
             // check translation
             $translated_field = '';
             if (parent::lang('class.AdministrationView#tableRows#name#' . $field) != "class.AdministrationView#tableRows#name#{$field} not translated") {
                 $translated_field = parent::lang('class.AdministrationView#tableRows#name#' . $field);
             } else {
                 $translated_field = $field;
             }
             // check field
             if (substr($field, 0, 5) != '_qf__' && $field != 'submit') {
                 // add fields to sql
                 $sql_field .= "{$field},";
                 $sql_value .= "'{$value}',";
                 // add fields to output
                 $return .= $this->p('', "{$translated_field} = '" . nl2br(htmlentities(utf8_decode($value))) . "'");
             }
         }
         $sql_field = substr($sql_field, 0, -1) . ")";
         $sql_value = substr($sql_value, 0, -1) . ")";
         $sql .= $sql_field . $sql_value;
         // execute
         $result = $db->query($sql);
         // add table content
         $return .= $this->list_table_content($table, $this->get('page'));
     } else {
         $return .= $this->p('', parent::lang('class.AdministrationView#new_row#caption#edit'));
         $return .= $form->render($renderer);
     }
     // return
     return $return;
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.AdministrationView.php

示例14: testGroup

 public function testGroup()
 {
     $value1 = array('foo' => 'foo');
     $value1F = array('foo' => 'F');
     $value2 = array('bar' => 'bar', 'baz' => array('quux' => 'baz'));
     $value2F = array('bar' => 'Bar', 'baz' => array('quux' => 'Baz'));
     $valueAnon = array('e1' => 'e1');
     $valueAnonF = array('e1' => '1');
     $formValue = array('g1' => $value1, 'g2' => array('i2' => $value2)) + $valueAnon;
     $formValueF = array('g1' => $value1F, 'g2' => array('i2' => $value2F)) + $valueAnonF;
     $form = new HTML_QuickForm2('testGroupGetValue');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($formValue));
     $g1 = $form->addGroup('g1');
     $g1->addRecursiveFilter('strtoupper');
     $el1 = $g1->addText('foo');
     // Trim O *after* strtoupper
     $el1->addFilter('trim', array('O'));
     $g2 = $form->addGroup('g2[i2]');
     $g2->addRecursiveFilter('ucfirst');
     $g2->addText('bar');
     $g2->addText('baz[quux]');
     $anon = $form->addGroup();
     $anon->addText('e1');
     $anon->addRecursiveFilter('substr', array(1, 1));
     $this->assertEquals($formValueF, $form->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:26,代码来源:FilterTest.php

示例15: user

 /**
  * user controles the actions for usersettings
  * 
  * @return string the html-string of usersettings-page
  */
 private function user()
 {
     // smarty-template
     $sUserPasswd = new JudoIntranetSmarty();
     // prepare return
     $return = '';
     // check login
     if ($_SESSION['user']->get_loggedin()) {
         // smarty
         $sUserPasswd->assign('pagecaption', parent::lang('class.MainView#user#caption#general') . ' ' . $_SESSION['user']->get_userinfo('name'));
         // check action
         if ($this->get('action') == 'passwd') {
             // smarty
             $sUserPasswd->assign('section', parent::lang('class.MainView#user#caption#passwd'));
             // prepare form
             $form = new HTML_QuickForm2('passwd', 'post', array('name' => 'passwd', 'action' => 'index.php?id=user&action=passwd'));
             // add elementgroup
             $passwd = $form->addElement('group', 'password', array());
             // add fields
             $passwd1 = $passwd->addElement('password', 'password1', array());
             $passwd2 = $passwd->addElement('password', 'password2', array());
             // add label
             $passwd->setLabel(parent::lang('class.MainView#user#passwd#label') . ':');
             // submit-button
             $form->addSubmit('submit', array('value' => parent::lang('class.MainView#user#passwd#submitButton')));
             // renderer
             $renderer = HTML_QuickForm2_Renderer::factory('default');
             $renderer->setOption('required_note', parent::lang('class.MainView#user#form#requiredNote'));
             // add rules
             $passwd->addRule('required', parent::lang('class.MainView#user#rule#required'));
             $passwd->addRule('callback', parent::lang('class.MainView#user#rule#checkPasswd'), array($this, 'callback_check_passwd'));
             // validate
             if ($form->validate()) {
                 // get values
                 $data = $form->getValue();
                 // get db-object
                 $db = Db::newDb();
                 // prepare sql-statement
                 $sql = "UPDATE user\n\t\t\t\t\t\t\tSET password='" . md5($data['password']['password1']) . "'\n\t\t\t\t\t\t\tWHERE id=" . $_SESSION['user']->get_id();
                 // execute statement
                 $result = $db->query($sql);
                 // smarty message
                 $sUserPasswd->assign('message', parent::lang('class.MainView#user#validate#passwdChanged'));
             } else {
                 // smarty form and return
                 $sUserPasswd->assign('form', $form->render($renderer));
             }
             return $sUserPasswd->fetch('smarty.user.passwd.tpl');
         } else {
             return 'default content';
         }
     } else {
         // not authorized
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:63,代码来源:class.MainView.php


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