本文整理汇总了PHP中HTML_QuickForm::getElement方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::getElement方法的具体用法?PHP HTML_QuickForm::getElement怎么用?PHP HTML_QuickForm::getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm
的用法示例。
在下文中一共展示了HTML_QuickForm::getElement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute() {
$request = $this->getContext()->getRequest();
$postLoginUser = $request->getParameter('user');
$postLoginId = $postLoginUser['id'];
$id = $request->getParameter('id');
$login = $this->getContext()->getUser()->getAttribute('Login');
$loginRole = $this->getLoginRole();
if ($loginRole == 'editor'){
if ($id != $login->id && $postLoginId != $login->id){
$this->log("Unauthorized attempt edit login record. Login id: $id, user name: ". $login->name);
$this->getContext()->getController()->forward('Default', "Secure");
}
}
// $this->checkAdminAuth();
if($request->getParameter('cancel')) {
if ($loginRole == 'admin'){
$this->getContext()->getController()->forward('Default', "ListLogin");
} else {
header("Location:Search?searchFor=Member");
}
return View::NONE;
}
$form = new HTML_QuickForm("loginForm", 'post');
$loginDao = new BaseDao("Login");
$affDao = new BaseDao("Affiliate");
if ($id){
$user = $loginDao->get($id);
$this->log("Editing login: ".$user->login." ,name: ".$user->name);
$this->log("Editing login: ".$user->login." ,name: ".$user->name, true);
$affiliate = $affDao->getPattern();
$affiliate->editor = $user->id;
$currentAffs = $affDao->search($affiliate);
$affIds = $this->getListOfCertainFieldValues($currentAffs, 'id');
$form->setDefaults(array('user' => (array) $user,
"password2" => $user->password,
"affiliates" => $affIds));
} else{
$this->log("Creating new login.", true);
$user = $loginDao->getPattern();
}
$request->setAttribute('user', $user);
$roleDao = new BaseDao("Role");
$roles = $this->prepareDropdown($roleDao->search(), 'id', 'name');
$affs = $this->prepareDropdown($affDao->searchWhereWithOrder($affDao->getPattern(), "1=1", 'name'), 'id', 'name');
$form->addElement("text", "user[name]", "Name:", array('size' => 50, "maxlength" => 255));
$form->addElement("text", "user[login]", "Login:", array('size' => 50, "maxlength" => 255));
$form->addElement("password", "user[password]", "Password:", array('size' => 50, "maxlength" => 255));
$form->addElement("password", "password2", "Repeat Password:", array('size' => 50, "maxlength" => 255));
$form->addElement('text', "user[email]", 'Email:', array('size' => 50, "maxlength" => 255));
$form->addElement('select', "user[roleFid]", "User Role:", $roles);
$form->addElement('select', "affiliates", "Affiliate:", $affs, array('multiple' => 'multiple', 'id' => "affDropdown") );
$form->addElement('checkbox', "user[nationalOfficer]", "National Officer:", "", array());
$element =& $form->getElement("affiliates");
$element->setSize(5);
if ($loginRole != 'admin') $element->freeze();
$form->addElement('hidden', 'user[id]');
$form->addElement("submit", null, "Save Changes");
$form->addElement("submit", 'cancel', "Cancel");
$form->addRule("user[name]", "Please enter your name.", 'required', null);
$form->addRule("user[login]", "Login can't be blank.", 'required', null);
$form->addRule("user[password]", "You haven't entered password.", 'required', null);
$form->addRule("user[email]", "Please enter your email.", 'required', null);
$form->addRule("user[email]", "Please enter valid email.", 'email', null);
$form->addFormRule(array(&$this, "validatePassword"));
$form->addFormRule(array(&$this, "checkEmail"));
$form->addFormRule(array(&$this, "max5admins"));
if (!$form->validate()) {
$request->setAttribute("editLoginForm", $form->toHtml());
//.........这里部分代码省略.........
示例2: array
* Different messages we put in the template
*/
$tpl->assign('msg', array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")));
/*
* Toolbar select
*/
?>
<script type="text/javascript">
function setO(_i) {
document.forms['form'].elements['o'].value = _i;
}
</SCRIPT>
<?php
$attrs = array('onchange' => "javascript: " . "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . _("Do you confirm the duplication ?") . "')) {" . " \tsetO(this.form.elements['o1'].value); submit();} " . "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . _("Do you confirm the deletion ?") . "')) {" . " \tsetO(this.form.elements['o1'].value); submit();} " . "else if (this.form.elements['o1'].selectedIndex == 3) {" . " \tsetO(this.form.elements['o1'].value); submit();} " . "");
$form->addElement('select', 'o1', NULL, array(NULL => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), $attrs);
$form->setDefaults(array('o1' => NULL));
$o1 = $form->getElement('o1');
$o1->setValue(NULL);
$attrs = array('onchange' => "javascript: " . "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . _("Do you confirm the duplication ?") . "')) {" . " \tsetO(this.form.elements['o2'].value); submit();} " . "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . _("Do you confirm the deletion ?") . "')) {" . " \tsetO(this.form.elements['o2'].value); submit();} " . "else if (this.form.elements['o2'].selectedIndex == 3) {" . " \tsetO(this.form.elements['o2'].value); submit();} " . "");
$form->addElement('select', 'o2', NULL, array(NULL => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), $attrs);
$form->setDefaults(array('o2' => NULL));
$o2 = $form->getElement('o2');
$o2->setValue(NULL);
$tpl->assign('limit', $limit);
/*
* Apply a template definition
*/
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form->accept($renderer);
$tpl->assign('form', $renderer->toArray());
$tpl->display("listCollectors.ihtml");
示例3: admin_display
function admin_display($task)
{
global $db, $cfg;
if ($task == NULL) {
$task = 'contests';
}
switch ($task) {
case 'users':
$table = new HTML_Table();
$res =& db_query('users_list');
$res->fetchInto($row);
// add users table headers
$headers = array_keys($row);
array_push($headers, 'groups');
array_push($headers, 'actions');
$table->addRow($headers, null, 'TH');
// add user records
while ($row) {
$res2 =& db_query('groups_by_user_id', $row['user_id']);
// get list of gourps for this user
$groups = '';
$res2->fetchInto($row2);
while ($row2) {
$groups .= $row2['name'];
if ($res2->fetchInto($row2)) {
$groups .= ', ';
}
}
$res2->free();
array_push($row, $groups);
// actions
array_push($row, "<a href=\"index.php?view=admin&task=edit_user&id={$row['user_id']}\">edit</a>" . ", <a href=\"index.php?view=admin&task=del_user&id={$row['user_id']}\">delete</a>");
$table->addRow(array_values($row));
$res->fetchInto($row);
}
$res->free();
$table->altRowAttributes(1, null, array("class" => "altrow"));
echo '<div class="overflow">' . $table->toHtml() . '</div>';
break;
case 'del_user':
db_query('del_user_by_id', $_GET['id']);
db_query('del_user_perms_by_id', $_GET['id']);
redirect('index.php?view=admin&task=users');
break;
case 'edit_user':
// user id to edit given as arg
$res =& db_query('groups_by_user_id', $_GET['id']);
// get list of all groups for this user
$user_groups = array();
while ($res->fetchInto($row)) {
array_push($user_groups, $row['group_id']);
}
$res->free();
// get hanndle of user
$res =& db_query('user_by_id', $_GET['id']);
$res->fetchInto($row);
$handle = $row['handle'];
$res->free();
$form = new HTML_QuickForm('userForm', 'post', 'index.php?view=admin&task=edit_user&id=' . $_GET['id']);
$form->addElement('header', null, 'Groups for user ' . $handle . ' (id: ' . $_GET['id'] . ')');
// get list of all available groups
$res =& db_query('groups_list');
// add checkbox for each group
$groups = array();
while ($res->fetchInto($row)) {
$elem =& $form->addElement('checkbox', $row['group_id'], $row['name']);
if (in_array($row['group_id'], $user_groups)) {
$elem->setChecked(true);
}
$groups[$row['group_id']] = $row['name'];
}
$res->free();
$form->addElement('submit', 'submit', 'Apply Changes');
if ($form->validate()) {
$data = $form->getSubmitValues();
foreach ($groups as $gid => $name) {
$elem =& $form->getElement($gid);
if ($data[$gid] == 1) {
auth_set_perm($_GET['id'], $gid);
$elem->setChecked(true);
} else {
auth_clear_perm($_GET['id'], $gid);
$elem->setChecked(false);
}
}
}
$form->display();
break;
case 'groups':
$table = new HTML_Table();
$res =& db_query('groups_list');
$res->fetchInto($row);
// add groups table header
$headers = array_keys($row);
array_push($headers, 'views');
array_push($headers, 'actions');
$table->addRow($headers, null, 'TH');
// add group records
while ($row) {
$res2 =& db_query('views_by_group_id', $row['group_id']);
//.........这里部分代码省略.........
示例4: array
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/livesearch_select.php';
require_once 'myfunction.php';
// Instantiate the HTML_QuickForm object
$form = new HTML_QuickForm('firstForm');
// Add some elements to the form
$form->addElement('header', null, 'QuickForm example');
$form->addElement('livesearch_select', 'Nome', 'Example: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array('elementId' => 'search', 'callback' => array('Test', 'getTestName'), 'style' => '', 'divstyle' => '', 'ulstyle' => '', 'listyle' => '', 'searchZeroLength' => 1, 'buffer' => 350, 'printStyle' => 1, 'autoComplete' => 1, 'autoserverPath' => ''), array('size' => '50'));
$form->addElement('livesearch_select', 'Nome2', 'Example2: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array('elementId' => 'search2', 'callback' => array('Test', 'getTestName2')), 'size=30');
$form->addElement('text', 'required_field', '[errorTest]Some data:');
$form->addElement('submit', null, 'View', array('id' => 'submit'));
$form->addRule('required_field', 'Data required', 'required', null, 'server');
$form->addRule('Nome', 'Data required', 'required', null, 'server');
//example set default value only if form is not submitted
if (!isset($_POST['Nome2'])) {
$el = $form->getElement('Nome2');
$el->setValue(2);
}
if ($form->validate()) {
echo "<pre>";
print_r($_POST);
echo "</pre>";
$form->freeze();
}
// Output the form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Livesearch QuickForm Test</title>
示例5: getModule
public function getModule()
{
$currentLesson = $this->getCurrentLesson();
$smarty = $this->getSmartyVar();
$smarty->assign("T_LESSON_ID", $currentLesson->lesson['id']);
if (isset($_GET['delete_link']) && eF_checkParameter($_GET['delete_link'], 'id')) {
eF_deleteTableData("module_links", "id=" . $_GET['delete_link']);
$this->setMessageVar(_LINKS_SUCCESFULLYDELETEDLINK, 'success');
eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type={$message_type}");
} else {
if (isset($_GET['add_link']) || isset($_GET['edit_link']) && eF_checkParameter($_GET['edit_link'], 'id')) {
$form = new HTML_QuickForm("link_entry_form", "POST", $_SERVER['REQUEST_URI'], "");
$form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$form->addElement('text', 'display', null);
$form->addElement('text', 'link', null);
$form->addElement('textarea', 'description', null);
$form->addElement('submit', 'submit_link', _SUBMIT, 'class = "flatButton"');
$element =& $form->getElement('display');
$element->setSize(50);
$element =& $form->getElement('link');
$element->setSize(50);
$element =& $form->getElement('description');
$element->setCols(50);
if (isset($_GET['edit_link'])) {
$link_entry = eF_getTableData("module_links", "*", "id=" . $_GET['edit_link']);
$form->setDefaults(array('display' => $link_entry[0]['display'], 'link' => $link_entry[0]['link'], 'description' => $link_entry[0]['description']));
} else {
$form->setDefaults(array('link' => "http://"));
}
if ($form->isSubmitted() && $form->validate()) {
$fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'display' => $form->exportValue('display'), 'link' => $form->exportValue('link'), 'description' => $form->exportValue('description'));
if (isset($_GET['edit_link'])) {
if (eF_updateTableData("module_links", $fields, "id=" . $_GET['edit_link'])) {
$message = _LINKS_SUCCESFULLYUPDATEDLINKENTRY;
$message_type = 'success';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
} else {
$message = _LINKS_PROBLEMUPDATINGLINKENTRY;
$message_type = 'failure';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
}
} else {
if (eF_insertTableData("module_links", $fields)) {
$message = _LINKS_SUCCESFULLYINSERTEDLINKENTRY;
$message_type = 'success';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
} else {
$message = _LINKS_PROBLEMINSERTINGLINKENTRY;
$message_type = 'failure';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
}
}
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$form->accept($renderer);
$smarty->assign('T_LINKS_FORM', $renderer->toArray());
} else {
$links = eF_getTableDataFlat("module_links", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']);
$smarty->assign("T_LINKS", $links);
}
}
return true;
}
示例6: fclose
fclose($stream);
}
break;
break;
case 'courses':
$token = $values['token'];
if ($stream = fopen(G_SERVERNAME . 'api.php?action=courses&token=' . $token, 'r')) {
$output = stream_get_contents($stream);
fclose($stream);
}
break;
break;
case 'logout':
$token = $values['token'];
if ($stream = fopen(G_SERVERNAME . 'api.php?action=logout&token=' . $token, 'r')) {
$output = stream_get_contents($stream);
fclose($stream);
}
break;
}
}
}
$form->setDefaults(array('action' => $action_id));
$element =& $form->getElement('output');
$element->setValue($output);
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
$form->setRequiredNote(_REQUIREDNOTE);
$form->accept($renderer);
$smarty->assign('T_ACTION_FORM', $renderer->toArray());
$smarty->display('apidemo.tpl');
示例7: _populateHierarchy
private function _populateHierarchy($id, $hierarchy_id)
{
$element =& $this->_form->getElement($id);
$hierarchy =& TIP_Type::getInstance($hierarchy_id);
if ($element->isFrozen()) {
// No need to execute a complete query: get only the selected row(s)
$selected = $element->getSelected();
$items = $hierarchy->toRow($selected);
} else {
// Populate the option list, prepending an empty option
$items = array(' ' => ' ');
is_null($rows =& $hierarchy->toRows()) || ($items += $rows);
}
$element->loadArray($items);
}
示例8: array
$create_db_warn_msg = __('WARNING: Make sure you have CREATE access level to do this!');
$form->addElement('select', 'newdb', __('Create new database'), array(0 => __('No'), 1 => __('Yes')), array('onChange' => 'if(this.value==1) alert("' . $create_db_warn_msg . '","warning");'));
$form->addRule('newdb', __('Field required'), 'required');
$form->addElement('header', null, __('Other settings'));
$form->addElement('select', 'direction', __('Text direction'), array(0 => __('Left to Right'), 1 => __('Right to Left')));
$form->addElement('submit', 'submit', __('Next'));
$form->setDefaults(array('engine' => 'mysqlt', 'db' => 'epesi', 'host' => 'localhost'));
$form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . __('denotes required field') . '</span>');
if (file_exists($fast_install_filename)) {
include $fast_install_filename;
if (isset($CONFIG) && is_array($CONFIG)) {
$txt = __('Some fields were filled to make installation easier.');
print '<div style="text-align:center"><p style="width: 250px;margin-left: auto;margin-right: auto;">' . $txt . '</p></div>';
foreach ($CONFIG as $key => $value) {
$form->setDefaults(array($key => $value));
$form->getElement($key)->freeze();
}
}
}
$required_note_text = __('denotes required field');
$form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . $required_note_text . '</span>');
$form->addElement('html', '<tr><td colspan=2><br /><b>' . __('Any existing tables will be dropped!') . '</b><br />' . __('The database will be populated with data.') . '<br />' . __('This operation can take several minutes.') . '</td></tr>');
if ($form->validate()) {
$engine = $form->exportValue('engine');
$direction = $form->exportValue('direction');
$other = array('direction' => $direction);
$host = $form->exportValue('host');
$port = $form->exportValue('port');
$user = $form->exportValue('user');
$pass = $form->exportValue('password');
$dbname = $form->exportValue('db');
示例9: insertPollerInDB
$subC = $form->addElement('submit', 'submitC', _("Save"));
$res = $form->addElement('reset', 'reset', _("Reset"));
$form->setDefaults($cfg_poller);
} else {
if ($o == "a") {
/*
* Add a Poller information
*/
$subA = $form->addElement('submit', 'submitA', _("Save"));
$res = $form->addElement('reset', 'reset', _("Reset"));
}
}
}
$valid = false;
if ($form->validate()) {
$pollerObj = $form->getElement('id');
if ($form->getSubmitValue("submitA")) {
insertPollerInDB();
} else {
if ($form->getSubmitValue("submitC")) {
updatePollerInDB($id);
}
}
$o = NULL;
$valid = true;
}
if ($valid) {
require_once $path . "listCollectors.php";
} else {
/*
* Apply a template definition
示例10: getModule
public function getModule()
{
$currentLesson = $this->getCurrentLesson();
$smarty = $this->getSmartyVar();
$smarty->assign("T_LESSON_ID", $currentLesson->lesson['id']);
if (isset($_GET['delete_quote']) && eF_checkParameter($_GET['delete_quote'], 'id')) {
eF_deleteTableData("module_quote", "id=" . $_GET['delete_quote']);
$this->setMessageVar(_QUOTE_SUCCESFULLYDELETEDQUOTE, 'success');
eF_redirect("" . $this->moduleBaseUrl . "&message={$message}&message_type={$message_type}");
} else {
if (isset($_GET['add_quote']) || isset($_GET['edit_quote']) && eF_checkParameter($_GET['edit_quote'], 'id')) {
$form = new HTML_QuickForm("quote_entry_form", "POST", $_SERVER['REQUEST_URI'], "");
$form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$form->addElement('textarea', 'quote', null);
$form->addElement('submit', 'submit_quote', _SUBMIT, 'class = "flatButton"');
$element =& $form->getElement('quote');
$element->setCols(100);
if (isset($_GET['edit_quote'])) {
$quote_entry = eF_getTableData("module_quote", "*", "id=" . $_GET['edit_quote']);
$form->setDefaults(array('quote' => $quote_entry[0]['quote']));
}
if ($form->isSubmitted() && $form->validate()) {
$fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'quote' => $form->exportValue('quote'));
if (isset($_GET['edit_quote'])) {
if (eF_updateTableData("module_quote", $fields, "id=" . $_GET['edit_quote'])) {
$message = _QUOTE_SUCCESFULLYUPDATEDQUOTEENTRY;
$message_type = 'success';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_quote&message={$message}&message_type={$message_type}");
} else {
$message = _QUOTE_PROBLEMUPDATINGQUOTEENTRY;
$message_type = 'failure';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_quote&message={$message}&message_type={$message_type}");
}
} else {
if (eF_insertTableData("module_quote", $fields)) {
$message = _QUOTE_SUCCESFULLYINSERTEDQUOTEENTRY;
$message_type = 'success';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_quote&message={$message}&message_type={$message_type}");
} else {
$message = _QUOTE_PROBLEMINSERTINGQUOTEENTRY;
$message_type = 'failure';
eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_quote&message={$message}&message_type={$message_type}");
}
}
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$form->accept($renderer);
$smarty->assign('T_QUOTE_FORM', $renderer->toArray());
} else {
$currentUser = $this->getCurrentUser();
if ($currentUser->getType() == "professor") {
$quotes = eF_getTableDataFlat("module_quote", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']);
$smarty->assign("T_QUOTES", $quotes);
} else {
$quotes = eF_getTableDataFlat("module_quote", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']);
$id = rand(0, sizeof($quotes) - 1);
$smarty->assign("T_QUOTE", $quotes['quote'][$id]);
}
}
}
return true;
}
示例11: getElement
/**
*
* @param type $elem
* @return type
*/
public function getElement($elem)
{
return $this->formProcessor->getElement($elem);
}
示例12: updateReportInDB
$form->freeze();
} else {
if ($o == "c") {
$subC =& $form->addElement('submit', 'submitC', _("Save"));
$res =& $form->addElement('reset', 'reset', _("Reset"));
$form->setDefaults($report);
} else {
if ($o == "a") {
$subA =& $form->addElement('submit', 'submitA', _("Save"));
$res =& $form->addElement('reset', 'reset', _("Reset"));
}
}
}
$valid = false;
if ($form->validate()) {
$reportObj =& $form->getElement('report_id');
if ($form->getSubmitValue("submitA")) {
$reportObj->setValue(insertReportInDB());
} else {
if ($form->getSubmitValue("submitC")) {
updateReportInDB($reportObj->getValue());
}
}
$o = NULL;
$form->addElement("button", "change", _("Modify"), array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&report_id=" . $reportObj->getValue() . "'"));
$form->freeze();
$valid = true;
}
$action =& $form->getSubmitValue("action");
if ($valid && $action["action"]["action"]) {
require_once $path . "listReport.php";