本文整理汇总了PHP中object::addGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP object::addGroup方法的具体用法?PHP object::addGroup怎么用?PHP object::addGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::addGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addGroup
/**
* 增加新的用户组
*
* @param object $data
* @return boolean true|false
* @access public
*/
public function addGroup(GroupSave $data)
{
if (!$this->groupValidate->add($data)) {
return $this->setErrorMsg($this->groupValidate->getErrorMessage());
}
if (!$this->acl->checkGroupLevelPermission($data->level, Acl::GROUP_LEVEL_TYPE_LEVEL)) {
return $this->setErrorMsg(Lang::get('common.account_level_deny'));
}
if ($this->groupModel->addGroup($data->toArray()) !== false) {
return true;
}
return $this->setErrorMsg(Lang::get('common.action_error'));
}
示例2: array
/**
* Constructor Summary
*
* o Creates a standard progress bar into a dialog box (QuickForm).
* Form name, buttons 'start', 'cancel' labels and style, and
* title of dialog box may also be changed.
* <code>
* $monitor = new HTML_Progress_Monitor();
* </code>
*
* o Creates a progress bar into a dialog box, with only a new
* form name.
* <code>
* $monitor = new HTML_Progress_Monitor($formName);
* </code>
*
* o Creates a progress bar into a dialog box, with a new form name,
* new buttons name and style, and also a different title box.
* <code>
* $monitor = new HTML_Progress_Monitor($formName, $attributes);
* </code>
*
* @param string $formName (optional) Name of monitor dialog box (QuickForm)
* @param array $attributes (optional) List of renderer options
* @param array $errorPrefs (optional) Hash of params to configure error handler
*
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
*/
function HTML_Progress_Monitor($formName = 'ProgressMonitor', $attributes = array(), $errorPrefs = array())
{
$bar = new HTML_Progress($errorPrefs);
$this->_progress = $bar;
if (!is_string($formName)) {
return $this->_progress->raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$formName', 'was' => gettype($formName), 'expected' => 'string', 'paramnum' => 1));
} elseif (!is_array($attributes)) {
return $this->_progress->raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2));
}
$this->_id = md5(microtime());
$this->_form = new HTML_QuickForm($formName);
$this->_form->removeAttribute('name');
// XHTML compliance
$this->windowname = isset($attributes['title']) ? $attributes['title'] : 'In progress ...';
$this->buttonStart = isset($attributes['start']) ? $attributes['start'] : 'Start';
$this->buttonCancel = isset($attributes['cancel']) ? $attributes['cancel'] : 'Cancel';
$buttonAttr = isset($attributes['button']) ? $attributes['button'] : '';
$this->_form->addElement('header', 'windowname', $this->windowname);
$this->_form->addElement('static', 'progressBar');
$this->_form->addElement('static', 'progressStatus');
$style = $this->isStarted() ? array('disabled' => 'true') : null;
$buttons[] =& $this->_form->createElement('submit', 'start', $this->buttonStart, $style);
$buttons[] =& $this->_form->createElement('submit', 'cancel', $this->buttonCancel);
$buttons[0]->updateAttributes($buttonAttr);
$buttons[1]->updateAttributes($buttonAttr);
$this->_form->addGroup($buttons, 'buttons', '', ' ', false);
// default embedded progress element with look-and-feel
$this->setProgressElement($bar);
$str =& $this->_form->getElement('progressStatus');
$str->setText('<div id="status" class="progressStatus"> </div>');
}
示例3: add_unit_options
/**
* Add the unit handling options to the form.
* @param object $mform the form being built.
*/
protected function add_unit_options($mform)
{
$mform->addElement('header', 'unithandling', get_string('unithandling', 'qtype_numerical'));
$unitoptions = array(qtype_numerical::UNITNONE => get_string('onlynumerical', 'qtype_numerical'), qtype_numerical::UNITOPTIONAL => get_string('manynumerical', 'qtype_numerical'), qtype_numerical::UNITGRADED => get_string('unitgraded', 'qtype_numerical'));
$mform->addElement('select', 'unitrole', get_string('unithandling', 'qtype_numerical'), $unitoptions);
$penaltygrp = array();
$penaltygrp[] = $mform->createElement('text', 'unitpenalty', get_string('unitpenalty', 'qtype_numerical'), array('size' => 6));
$mform->setType('unitpenalty', PARAM_FLOAT);
$mform->setDefault('unitpenalty', 0.1);
$unitgradingtypes = array(qtype_numerical::UNITGRADEDOUTOFMARK => get_string('decfractionofresponsegrade', 'qtype_numerical'), qtype_numerical::UNITGRADEDOUTOFMAX => get_string('decfractionofquestiongrade', 'qtype_numerical'));
$penaltygrp[] = $mform->createElement('select', 'unitgradingtypes', '', $unitgradingtypes);
$mform->setDefault('unitgradingtypes', 1);
$mform->addGroup($penaltygrp, 'penaltygrp', get_string('unitpenalty', 'qtype_numerical'), ' ', false);
$mform->addHelpButton('penaltygrp', 'unitpenalty', 'qtype_numerical');
$unitinputoptions = array(qtype_numerical::UNITINPUT => get_string('editableunittext', 'qtype_numerical'), qtype_numerical::UNITRADIO => get_string('unitchoice', 'qtype_numerical'), qtype_numerical::UNITSELECT => get_string('unitselect', 'qtype_numerical'));
$mform->addElement('select', 'multichoicedisplay', get_string('studentunitanswer', 'qtype_numerical'), $unitinputoptions);
$unitsleftoptions = array(0 => get_string('rightexample', 'qtype_numerical'), 1 => get_string('leftexample', 'qtype_numerical'));
$mform->addElement('select', 'unitsleft', get_string('unitposition', 'qtype_numerical'), $unitsleftoptions);
$mform->setDefault('unitsleft', 0);
$mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITNONE);
$mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL);
$mform->disabledIf('unitsleft', 'unitrole', 'eq', qtype_numerical::UNITNONE);
$mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITNONE);
$mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL);
}
示例4: array
/**
* The progress uploader class constructor
*
* @param string $formName (optional) Name of monitor dialog box (QuickForm)
* @param array $attributes (optional) List of renderer options
*
* @since 1.1
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
*/
function HTML_Progress_Uploader($formName = 'ProgressUploader', $attributes = array())
{
$this->_package = 'HTML_Progress_Uploader';
Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
if (!is_string($formName)) {
return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$formName', 'was' => gettype($formName), 'expected' => 'string', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
} elseif (!is_array($attributes)) {
return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
}
parent::FTP_Upload();
// checks all necessary dependencies
$this->_form = new HTML_QuickForm($formName);
$this->windowname = isset($attributes['title']) ? $attributes['title'] : 'Upload ...';
$this->captionMask = isset($attributes['mask']) ? $attributes['mask'] : '%s';
$this->buttonStart = isset($attributes['start']) ? $attributes['start'] : 'Start';
$this->buttonCancel = isset($attributes['cancel']) ? $attributes['cancel'] : 'Cancel';
$buttonAttr = isset($attributes['button']) ? $attributes['button'] : '';
$this->_form->addElement('header', 'windowname', $this->windowname);
$this->_form->addElement('static', 'progressBar');
$this->_form->addElement('static', 'progressStatus');
$style = $this->isStarted() ? array('disabled' => 'true') : null;
$buttons[] =& $this->_form->createElement('submit', 'start', $this->buttonStart, $style);
$buttons[] =& $this->_form->createElement('submit', 'cancel', $this->buttonCancel);
$buttons[0]->updateAttributes($buttonAttr);
$buttons[1]->updateAttributes($buttonAttr);
$this->_form->addGroup($buttons, 'buttons', '', ' ', false);
// default embedded progress element with look-and-feel
$this->_progress = new HTML_Progress();
$this->setProgressElement($this->_progress);
$str =& $this->_form->getElement('progressStatus');
$str->setText('<div id="status" class="progressStatus"> </div>');
}
示例5: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $userRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded, $useRequired, $search = false, $label = null)
{
$field =& new CRM_Core_DAO_CustomField();
$field->id = $fieldId;
if (!$field->find(true)) {
/* FIXME: failure! */
return null;
}
if (!isset($label)) {
$label = $field->label;
}
/**
* This was split into a different function before. however thanx to php4's bug with references,
* it was not working, so i munged it back into one big function - lobo
*/
switch ($field->html_type) {
case 'Text':
if ($field->is_search_range && $search) {
$qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
$qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
} else {
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, ($useRequired || $field->is_required) && !$search);
}
break;
case 'TextArea':
$attributes = '';
if ($field->note_rows) {
$attributes .= 'rows=' . $field->note_rows;
} else {
$attributes .= 'rows=4';
}
if ($field->note_columns) {
$attributes .= ' cols=' . $field->note_columns;
} else {
$attributes .= ' cols=60';
}
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $attributes, ($useRequired || $field->is_required) && !$search);
break;
case 'Select Date':
if ($field->is_search_range && $search) {
$qf->add('date', $elementName . '_from', $label . ' ' . ts('From'), CRM_Core_SelectValues::date('custom', $field->start_date_years, $field->end_date_years, $field->date_parts), ($useRequired || $field->is_required) && !$search);
$qf->add('date', $elementName . '_to', $label . ' ' . ts('To'), CRM_Core_SelectValues::date('custom', $field->start_date_years, $field->end_date_years, $field->date_parts), ($useRequired || $field->is_required) && !$search);
} else {
$qf->add('date', $elementName, $label, CRM_Core_SelectValues::date('custom', $field->start_date_years, $field->end_date_years, $field->date_parts), ($useRequired || $field->is_required) && !$search);
}
break;
case 'Radio':
$choice = array();
if ($field->data_type != 'Boolean') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($field->id, $inactiveNeeded);
foreach ($customOption as $v) {
$choice[] = $qf->createElement('radio', null, '', $v['label'], $v['value'], $field->attributes);
}
$qf->addGroup($choice, $elementName, $label);
} else {
$choice[] = $qf->createElement('radio', null, '', ts('Yes'), '1', $field->attributes);
$choice[] = $qf->createElement('radio', null, '', ts('No'), '0', $field->attributes);
$qf->addGroup($choice, $elementName, $label);
}
if (($useRequired || $field->is_required) && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Select':
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($field->id, $inactiveNeeded);
$selectOption = array();
foreach ($customOption as $v) {
$selectOption[$v['value']] = $v['label'];
}
$qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, ($useRequired || $field->is_required) && !$search);
break;
//added for select multiple
//added for select multiple
case 'Multi-Select':
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($field->id, $inactiveNeeded);
$selectOption = array();
foreach ($customOption as $v) {
$selectOption[$v['value']] = $v['label'];
}
$qf->addElement('select', $elementName, $label, $selectOption, array("size" => "5", "multiple"));
if (($useRequired || $field->is_required) && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'CheckBox':
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($field->id, $inactiveNeeded);
$check = array();
//.........这里部分代码省略.........
示例6: setupForm
/**
* Adds controls specific to this filter in the form.
* @param object $mform A MoodleForm object to setup
*/
public function setupForm(&$mform)
{
global $CFG;
$report = $this->_parent_report;
$filter = $this->_uniqueid;
$filter_js = array('var ac_show_panel = function( url ) {
var x = window.open(url, \'newWindow\', \'height=700,width=650,resizable=yes,scrollbars=yes,screenX=50,screenY=50\');
}
window.ac_show_panel = ac_show_panel;');
$filt_action_url_base = $CFG->wwwroot . '/local/eliscore/lib/form/autocomplete.php?report=' . $report . '&filter=' . $filter;
if ($this->_ui === 'inline') {
$mform->addElement('hidden', $this->_uniqueid, $this->get_default(), array('id' => 'id_' . $this->_uniqueid));
$mform->setType($this->_uniqueid, PARAM_TEXT);
$search_url = $filt_action_url_base . '&mode=search&q=';
$config_url = $filt_action_url_base . '&mode=config';
$main_input_ph = $this->_selection_enabled === true ? get_string('filt_autoc_typetosearch', 'local_eliscore') : '';
$text_input = array($mform->createElement('text', $this->_uniqueid, $this->_label, array('placeholder' => $main_input_ph)));
if ($this->config_allowed() === true) {
$text_input[] = $mform->createElement('static', 'configlink', '', '<a onclick="ac_show_panel(\'' . $config_url . '\');" href="#">' . '<img src=' . $CFG->wwwroot . '/local/elisprogram/pix/configuration.png>' . '</a>');
}
$text_input[] = $mform->createElement('html', '<div id="search_results_outer" class="filt_ac_res filt_ac_res_inline">
<div id="search_status" class="filt_ac_status filt_ac_status_inline"></div>
<div id="search_results"></div>
</div>');
$mform->addGroup($text_input, 'grp', $this->_label);
$mform->setType($this->_uniqueid, PARAM_RAW);
if ($this->_selection_enabled === true) {
if ($this->_required) {
// This adds red * & that a required form field exists + validation
$mform->addGroupRule('grp', get_string('required'), 'required', null, 1, 'client');
if ($this->_useid) {
$mform->addRule($this->_uniqueid, get_string('required'), 'required', null, 'client');
// hidden doesn't display
}
}
$mform->addElement('html', "<link rel='stylesheet' type='text/css' href='{$CFG->wwwroot}/local/eliscore/lib/form/autocomplete.css' />");
$mform->addElement('html', "<script src='{$CFG->wwwroot}/local/eliscore/js/jquery-1.7.1.min.js'></script>");
$mform->addElement('html', "<script src='{$CFG->wwwroot}/local/eliscore/lib/form/autocomplete.js'></script>");
$filter_js[] = "var search_textbox = 'id_grp_{$this->_uniqueid}';\n var search_results = 'search_results';\n var search_status = 'search_status';\n var search_results_outer = 'search_results_outer';\n\n var autocomplete = new autocomplete_ui(search_textbox,search_results,search_status,'{$search_url}','search_results_outer');\n autocomplete.str_searching = '" . get_string('filt_autoc_searching', 'local_eliscore') . "';\n autocomplete.str_typetosearch = '" . get_string('filt_autoc_typetosearch', 'local_eliscore') . "';\n\n \$('#'+search_textbox).focus().click(function(e){e.stopPropagation();}).keyup(function(e) {\n if (e.keyCode != 13) {\n \$('#'+search_results_outer).show().click(function(e) { e.stopPropagation() });\n \$('body').click(function(e){ \$('#'+search_results_outer).hide(); });\n var pos = \$(this).position();\n var height = \$(this).outerHeight();\n \$('#'+search_results_outer).css('left',pos.left+2).css('top',(pos.top+height+2));\n }\n });";
} else {
$mform->freeze('grp');
}
if (!empty($this->_default_label)) {
$mform->setDefault('grp[' . $this->_uniqueid . ']', $this->_default_label);
}
} else {
$popup_link = '<span id="id_' . $this->_uniqueid . '_label"></span> ';
if ($this->_selection_enabled === true) {
$popup_link .= '<a onclick="ac_show_panel(\'' . $filt_action_url_base . '\');" href="#">' . get_string('filt_autoc_select', 'local_eliscore') . '</a>';
}
$mform->addElement('static', 'selector', $this->_label, $popup_link);
$mform->addElement('html', '<div style="display:none;">');
$mform->addElement('text', $this->_uniqueid . '_labelsave', '');
$mform->setType($this->_uniqueid . '_labelsave', PARAM_TEXT);
$mform->addElement('text', $this->_uniqueid, '');
$mform->setType($this->_uniqueid, PARAM_TEXT);
if (!empty($this->_default_label)) {
$mform->setDefault($this->_uniqueid . '_labelsave', $this->_default_label);
}
if (!empty($this->_default_id)) {
$mform->setDefault($this->_uniqueid, $this->_default_id);
}
$mform->addElement('html', '</div>');
if (!empty($this->_filterhelp) && is_array($this->_filterhelp) && isset($this->_filterhelp[2])) {
//$mform->addHelpButton('selector', $this->_filterhelp[0], $this->_filterhelp[2]);
}
$filter_js[] = 'labelsave = document.getElementById(\'id_' . $this->_uniqueid . '_labelsave\');
labeldisp = document.getElementById(\'id_' . $this->_uniqueid . '_label\');
if (labelsave != null && labeldisp != null) {
labeldisp.innerHTML = labelsave.value;
}';
}
$mform->addElement('html', '<script>' . implode("\n\n", $filter_js) . '</script>');
}
示例7: addQuickFormElement
//.........这里部分代码省略.........
$opt['label'] = CRM_Utils_Array::value('label', $opt) ? $opt['label'] : '';
$opt['label'] = '<span class="crm-price-amount-amount">' . CRM_Utils_Money::format($opt[$valueFieldName]) . '</span> <span class="crm-price-amount-label">' . $opt['label'] . '</span>';
}
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
$extra = array('price' => json_encode(array($elementName, $priceVal)), 'data-amount' => $opt[$valueFieldName], 'data-currency' => $currencyName);
if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') {
$extra += array('onclick' => 'clearAmountOther();');
} elseif (!empty($qf->_quickConfig) && $field->name == 'membership_amount') {
$extra += array('onclick' => "return showHideAutoRenew({$opt['membership_type_id']});", 'membership-type' => $opt['membership_type_id']);
$qf->assign('membershipFieldID', $field->id);
}
$choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
if ($is_pay_later) {
$qf->add('text', 'txt-' . $elementName, $label, array('size' => '4'));
}
// CRM-6902
if (in_array($opId, $feezeOptions)) {
$choice[$opId]->freeze();
}
}
if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') {
$choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1', array('onclick' => 'clearAmountOther();'));
}
if (!$field->is_required) {
// add "none" option
if (CRM_Utils_Array::value('is_allow_other_amount', $otherAmount) && $field->name == 'contribution_amount') {
$none = ts('Other Amount');
} elseif (!empty($qf->_membershipBlock) && !CRM_Utils_Array::value('is_required', $qf->_membershipBlock) && $field->name == 'membership_amount') {
$none = ts('No thank you');
} else {
$none = ts('- none -');
}
$choice[] = $qf->createElement('radio', NULL, '', $none, '0', array('price' => json_encode(array($elementName, '0'))));
}
$element =& $qf->addGroup($choice, $elementName, $label);
// make contribution field required for quick config when membership block is enabled
if (($field->name == 'membership_amount' || $field->name == 'contribution_amount') && !empty($qf->_membershipBlock) && !$field->is_required) {
$useRequired = $field->is_required = TRUE;
}
if ($useRequired && $field->is_required) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Select':
$selectOption = $allowedOptions = $priceVal = array();
foreach ($customOption as $opt) {
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$selectOption[$opt['id']] = $opt['label'];
if (!in_array($opt['id'], $feezeOptions)) {
$allowedOptions[] = $opt['id'];
}
if ($is_pay_later) {
$qf->add('text', 'txt-' . $elementName, $label, array('size' => '4'));
}
}
$element =& $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && $field->is_required, array('price' => json_encode($priceVal)));
// CRM-6902
$button = substr($qf->controller->getButtonName(), -4);
if (!empty($feezeOptions) && $button != 'skip') {
$qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/");
}
break;
case 'CheckBox':
$check = array();
foreach ($customOption as $opId => $opt) {
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$check[$opId] =& $qf->createElement('checkbox', $opt['id'], NULL, $opt['label'], array('price' => json_encode(array($opt['id'], $priceVal)), 'data-amount' => $opt[$valueFieldName], 'data-currency' => $currencyName));
if ($is_pay_later) {
$txtcheck[$opId] =& $qf->createElement('text', $opId, $opt['label'], array('size' => '4'));
$qf->addGroup($txtcheck, 'txt-' . $elementName, $label);
}
// CRM-6902
if (in_array($opId, $feezeOptions)) {
$check[$opId]->freeze();
}
}
$element =& $qf->addGroup($check, $elementName, $label);
if ($useRequired && $field->is_required) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
}
if (isset($qf->_online) && $qf->_online) {
$element->freeze();
}
}
示例8: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $useRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded, $useRequired = true, $label = null, $fieldOptions = null, $feezeOptions = array())
{
require_once 'CRM/Utils/Money.php';
$field = new CRM_Price_DAO_Field();
$field->id = $fieldId;
if (!$field->find(true)) {
/* FIXME: failure! */
return null;
}
$config = CRM_Core_Config::singleton();
$qf->assign('currencySymbol', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name'));
if (!isset($label)) {
$label = $field->label;
}
if (isset($qf->_online) && $qf->_online) {
$useRequired = false;
}
$customOption = $fieldOptions;
if (!is_array($customOption)) {
$customOption = CRM_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
}
//use value field.
$valueFieldName = 'amount';
$seperator = '|';
switch ($field->html_type) {
case 'Text':
$optionKey = key($customOption);
$count = CRM_Utils_Array::value('count', $customOption[$optionKey], '');
$max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], '');
$priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value));
//check for label.
if (CRM_Utils_Array::value('label', $fieldOptions[$optionKey])) {
$label = $fieldOptions[$optionKey]['label'];
}
if ($field->is_display_amounts) {
$label .= ' - ';
$label .= CRM_Utils_Money::format(CRM_Utils_Array::value($valueFieldName, $customOption[$optionKey]));
}
$element =& $qf->add('text', $elementName, $label, array_merge(array('size' => "4"), array('price' => json_encode(array($optionKey, $priceVal)))), $useRequired && $field->is_required);
// CRM-6902
if (in_array($optionKey, $feezeOptions)) {
$element->freeze();
}
// integers will have numeric rule applied to them.
$qf->addRule($elementName, ts('%1 must be an integer (whole number).', array(1 => $label)), 'positiveInteger');
break;
case 'Radio':
$choice = array();
foreach ($customOption as $opId => $opt) {
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
$choice[$opId] = $qf->createElement('radio', null, '', $opt['label'], $opt['id'], array('price' => json_encode(array($elementName, $priceVal))));
// CRM-6902
if (in_array($opId, $feezeOptions)) {
$choice[$opId]->freeze();
}
}
if (!$field->is_required) {
// add "none" option
$choice[] = $qf->createElement('radio', null, '', '-none-', '0', array('price' => json_encode(array($elementName, "0"))));
}
$element =& $qf->addGroup($choice, $elementName, $label);
if ($useRequired && $field->is_required) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Select':
$selectOption = $allowedOptions = $priceVal = array();
foreach ($customOption as $opt) {
$count = CRM_Utils_Array::value('count', $opt, '');
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$selectOption[$opt['id']] = $opt['label'];
if (!in_array($opt['id'], $feezeOptions)) {
$allowedOptions[] = $opt['id'];
}
}
$element =& $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && $field->is_required, array('price' => json_encode($priceVal)));
//.........这里部分代码省略.........
示例9: setup_contact
/**
* Add form elements for course contact information.
* @param object $mform form definition
* @param object $courseinfo a record of general information from course info table.
* @param object $contactinfo a record of contact information from course instructor table.
* @return void
*/
private function setup_contact($mform, $courseinfo, $contactinfo)
{
global $CFG, $DB, $USER;
//Declare our globals for use
global $course;
$mform->addElement('html', '<a name="contact"></a>');
// anchor
$mform->addElement('header', 'course_contact_header', get_string('course_contact_header', 'local_metadata'));
// Email
$course_email = $mform->addElement('text', 'course_email', get_string('course_email', 'local_metadata'), '');
if ($contactinfo) {
$mform->setDefault('course_email', $contactinfo->email);
} else {
$mform->setDefault('course_email', $USER->email);
}
//$mform->addRule('course_email', get_string('err_required', 'local_metadata'), 'required', null, 'client');
$mform->addRule('course_email', get_string('err_email', 'local_metadata'), 'email', null, 'client');
$mform->setType('course_email', PARAM_TEXT);
// Phone
$course_phone = $mform->addElement('text', 'course_phone', get_string('course_phone', 'local_metadata'), '');
if ($contactinfo) {
$mform->setDefault('course_phone', $contactinfo->phonenumber);
}
$mform->setType('course_phone', PARAM_TEXT);
// Office
$course_office = $mform->addElement('text', 'course_office', get_string('course_office', 'local_metadata'), '');
if ($contactinfo) {
$mform->setDefault('course_office', $contactinfo->officelocation);
}
//$mform->addRule('course_office', get_string('err_required', 'local_metadata'), 'required', null, 'client');
$mform->setType('course_office', PARAM_TEXT);
// Office hours
// Set default hours
$mform->addElement('advcheckbox', 'default_officeh', get_string('course_officeh', 'local_metadata'), get_string('default_officeh', 'local_metadata'), null, array(0, get_string('default_officeh', 'local_metadata')));
$mform->addHelpButton('default_officeh', 'default_officeh', 'local_metadata');
// Set day
$daygroup = array();
foreach (get_days() as $day) {
$daygroup[] =& $mform->createElement('advcheckbox', $day, '', $day, null, array(0, $day));
}
$mform->addGroup($daygroup, 'daygroup', '', array(' '), false);
// Set time
$timegroup = array();
$hour = array();
for ($i = 0; $i < 13; $i++) {
$hour[] = sprintf("%02d", $i);
}
$minute = array();
for ($i = 0; $i < 60; $i++) {
$minute[] = sprintf("%02d", $i);
}
$time_format = array('AM', 'PM');
$timegroup[] =& $mform->createElement('static', 'fromhour_label', '', get_string('fromhour_label', 'local_metadata'));
$timegroup[] =& $mform->createElement('select', 'fromhour', '', $hour, '');
$timegroup[] =& $mform->createElement('select', 'fromminute', '', $minute, '');
$timegroup[] =& $mform->createElement('select', 'fromformat', '', $time_format, '');
$timegroup[] =& $mform->createElement('static', 'tohour_label', '', get_string('tohour_label', 'local_metadata'));
$timegroup[] =& $mform->createElement('select', 'tohour', '', $hour, '');
$timegroup[] =& $mform->createElement('select', 'tominute', '', $minute, '');
$timegroup[] =& $mform->createElement('select', 'toformat', '', $time_format, '');
$mform->addGroup($timegroup, 'timegroup', '', array(' '), false);
$mform->disabledIf('daygroup', 'default_officeh', 'checked');
$mform->disabledIf('timegroup', 'default_officeh', 'checked');
if (empty($contactinfo->officehours)) {
$mform->setDefault('default_officeh', true);
} else {
if ($contactinfo->officehours == 'By appointment') {
$mform->setDefault('default_officeh', true);
} else {
$formats = explode(" ", $contactinfo->officehours);
$mform->setDefault('toformat', array_pop($formats) == 'AM' ? 0 : 1);
$totimes = explode(":", array_pop($formats));
$mform->setDefault('tohour', $totimes[0]);
$mform->setDefault('tominute', $totimes[1]);
array_pop($formats);
$mform->setDefault('fromformat', array_pop($formats) == 'AM' ? 0 : 1);
$fromtimes = explode(":", array_pop($formats));
$mform->setDefault('fromhour', $fromtimes[0]);
$mform->setDefault('fromminute', $fromtimes[1]);
foreach ($formats as $day) {
$mform->setDefault($day, true);
}
}
}
$mform->addElement('static', 'h_2', '');
// end of header
$mform->setType('h_2', PARAM_RAW);
$mform->closeHeaderBefore('h_2');
$mform->setExpanded('course_contact_header');
}
示例10: buildAmount
/**
* build the radio/text form elements for the amount field
*
* @param object $form form object
* @param boolean $required true if you want to add formRule
* @param int $discountId discount id for the event
*
* @return void
* @access public
* @static
*/
public static function buildAmount(&$form, $required = true, $discountId = null)
{
//get the button name.
$button = substr($form->controller->getButtonName(), -4);
if ($button == 'skip') {
$required = false;
}
$elements = array();
if (isset($form->_priceSetId)) {
$form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
$form->add('hidden', 'priceSetId', $form->_priceSetId);
$form->assign('priceSet', $form->_priceSet);
require_once 'CRM/Price/BAO/Field.php';
foreach ($form->_values['fee']['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'price_' . $fieldId;
if ($button == 'skip') {
$isRequire = false;
} else {
$isRequire = CRM_Utils_Array::value('is_required', $field);
}
CRM_Price_BAO_Field::addQuickFormElement($form, $elementName, $fieldId, false, $isRequire);
}
} else {
if (!empty($form->_values['fee'])) {
$form->_feeBlock =& $form->_values['fee'];
if (isset($form->_values['discount'])) {
if (!isset($discountId) && $form->_action != CRM_Core_Action::UPDATE) {
require_once 'CRM/Core/BAO/Discount.php';
$form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
}
if ($discountId) {
$form->_feeBlock =& $form->_values['discount'][$discountId];
}
}
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::buildAmount('event', $form, $form->_feeBlock);
if ($form->_action != CRM_Core_Action::UPDATE) {
require_once 'CRM/Utils/Money.php';
foreach ($form->_feeBlock as $fee) {
if (is_array($fee)) {
$elements[] =& $form->createElement('radio', null, '', CRM_Utils_Money::format($fee['value']) . ' ' . $fee['label'], $fee['amount_id']);
}
}
$form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']);
$element =& $form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
if (isset($form->_online) && $form->_online) {
$element->freeze();
}
if ($required) {
$form->addRule('amount', ts('Fee Level is a required field.'), 'required');
}
}
}
}
}
示例11: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $userRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded = FALSE, $useRequired = TRUE, $search = FALSE, $label = NULL)
{
// we use $_POST directly, since we dont want to use session memory, CRM-4677
if (isset($_POST['_qf_Relationship_refresh']) && ($_POST['_qf_Relationship_refresh'] == 'Search' || $_POST['_qf_Relationship_refresh'] == 'Search Again')) {
$useRequired = FALSE;
}
$field = self::getFieldObject($fieldId);
// Custom field HTML should indicate group+field name
$groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id);
$dataCrmCustomVal = $groupName . ':' . $field->name;
$dataCrmCustomAttr = 'data-crm-custom="' . $dataCrmCustomVal . '"';
$field->attributes .= $dataCrmCustomAttr;
// Fixed for Issue CRM-2183
if ($field->html_type == 'TextArea' && $search) {
$field->html_type = 'Text';
}
// FIXME: Why are select state/country separate widget types?
if (in_array($field->html_type, array('Select', 'Multi-Select', 'Select State/Province', 'Multi-Select State/Province', 'Select Country', 'Multi-Select Country'))) {
$selectAttributes = array('data-crm-custom' => $dataCrmCustomVal, 'class' => 'crm-select2');
if (strpos($field->html_type, 'Multi') === 0) {
$selectAttributes['multiple'] = 'multiple';
}
}
// Add popup link for editing options. Normally this is handled by CRM_Core_Form->addSelect
if (in_array($field->html_type, array('Select', 'Multi-Select')) && !$search && CRM_Core_Permission::check('administer CiviCRM')) {
$selectAttributes += array('data-api-entity' => 'contact', 'data-api-field' => 'custom_' . $field->id, 'data-option-group-url' => 'civicrm/admin/options/' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $field->option_group_id));
}
if (!isset($label)) {
$label = $field->label;
}
/**
* at some point in time we might want to split the below into small functions
**/
switch ($field->html_type) {
case 'Text':
if ($field->is_search_range && $search) {
$qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
$qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
} else {
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, $useRequired && !$search);
}
break;
case 'TextArea':
$attributes = $dataCrmCustomAttr;
if ($field->note_rows) {
$attributes .= 'rows=' . $field->note_rows;
} else {
$attributes .= 'rows=4';
}
if ($field->note_columns) {
$attributes .= ' cols=' . $field->note_columns;
} else {
$attributes .= ' cols=60';
}
if ($field->text_length) {
$attributes .= ' maxlength=' . $field->text_length;
}
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $attributes, $useRequired && !$search);
break;
case 'Select Date':
if ($field->is_search_range && $search) {
$qf->addDate($elementName . '_from', $label . ' - ' . ts('From'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
$qf->addDate($elementName . '_to', ts('To'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
} else {
$required = $useRequired && !$search;
$qf->addDate($elementName, $label, $required, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
}
break;
case 'Radio':
$choice = array();
if ($field->data_type != 'Boolean') {
$customOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
foreach ($customOption as $v => $l) {
$choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $field->attributes);
}
$group = $qf->addGroup($choice, $elementName, $label);
} else {
$choice[] = $qf->createElement('radio', NULL, '', ts('Yes'), '1', $field->attributes);
$choice[] = $qf->createElement('radio', NULL, '', ts('No'), '0', $field->attributes);
$group = $qf->addGroup($choice, $elementName, $label);
}
if ($useRequired && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
} else {
$group->setAttribute('unselectable', TRUE);
}
break;
//.........这里部分代码省略.........
示例12: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $useRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded, $useRequired = true, $label = null)
{
require_once 'CRM/Utils/Money.php';
$field =& new CRM_Price_DAO_Field();
$field->id = $fieldId;
if (!$field->find(true)) {
/* FIXME: failure! */
return null;
}
$config =& CRM_Core_Config::singleton();
$qf->assign('currencySymbol', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name'));
if (!isset($label)) {
$label = $field->label;
}
if (isset($qf->_online) && $qf->_online) {
$useRequired = false;
}
//use value field.
$valueFieldName = 'value';
switch ($field->html_type) {
case 'Text':
$customOption = CRM_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
// text fields only have one option
$optionKey = key($customOption);
if ($field->is_display_amounts) {
$label .= ' - ';
$label .= CRM_Utils_Money::format(CRM_Utils_Array::value($valueFieldName, $customOption[$optionKey]));
}
$element =& $qf->add('text', $elementName, $label, array_merge(array('size' => "4"), array('price' => json_encode(array($optionKey, $customOption[$optionKey][$valueFieldName])))), $useRequired && $field->is_required);
// integers will have numeric rule applied to them.
$qf->addRule($elementName, ts('%1 must be an integer (whole number).', array(1 => $label)), 'positiveInteger');
break;
case 'Radio':
$choice = array();
$customOption = CRM_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
if (!$field->is_required) {
// add "none" option
$choice[] = $qf->createElement('radio', null, '', '-none-', '0', array('price' => json_encode(array($elementName, "0"))));
}
foreach ($customOption as $opt) {
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$choice[] = $qf->createElement('radio', null, '', $opt['label'], $opt['id'], array('price' => json_encode(array($elementName, $opt[$valueFieldName]))));
}
$element =& $qf->addGroup($choice, $elementName, $label);
if ($useRequired && $field->is_required) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Select':
$customOption = CRM_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
$selectOption = array();
foreach ($customOption as $opt) {
$amount[$opt['id']] = $opt[$valueFieldName];
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$selectOption[$opt['id']] = $opt['label'];
}
$element =& $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && $field->is_required, array('price' => json_encode($amount)));
break;
case 'CheckBox':
$customOption = CRM_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
$check = array();
foreach ($customOption as $opt) {
if ($field->is_display_amounts) {
$opt['label'] .= ' - ';
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
}
$check[] =& $qf->createElement('checkbox', $opt['id'], null, $opt['label'], array('price' => json_encode(array($opt['id'], $opt[$valueFieldName]))));
}
$element =& $qf->addGroup($check, $elementName, $label);
if ($useRequired && $field->is_required) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
}
if (isset($qf->_online) && $qf->_online) {
$element->freeze();
}
}
示例13: add_field_arrow
/**
* add_field_arrow
*
* @param object $mform
* @param string $plugin
* @param string $name
* @param array $arrows
* @param array $add_js
* @return void, but will update $mform
*/
protected function add_field_arrow($mform, $plugin, $name, $arrows, $add_js)
{
$config_name = 'config_' . $name;
$elements_name = 'elements_' . $name;
$static = array();
$params = array('href' => '#', 'onclick' => 'return select_arrow(this)');
foreach ($arrows as $arrow) {
$static[] = html_writer::tag('a', $arrow, $params);
}
$static = implode(' ', $static);
$static = html_writer::tag('span', $static, array('class' => 'arrows'));
$elements = array();
if ($add_js) {
$js = '';
$js .= '<script type="text/javascript">' . "\n";
$js .= "//<![CDATA[\n";
$js .= "function select_arrow(txt) {\n";
$js .= " var obj = txt.parentNode.previousSibling;\n";
$js .= " while (obj) {\n";
$js .= " if (obj.tagName=='INPUT') {\n";
$js .= " obj.value = txt.innerHTML;\n";
$js .= " obj = null;\n";
$js .= " } else {\n";
$js .= " obj = obj.previousSibling;\n";
$js .= " }\n";
$js .= " }\n";
$js .= " return false;\n";
$js .= "}\n";
$js .= "function select_all_courses(truefalse) {\n";
$js .= " var obj = document.getElementById('menumycourses');\n";
$js .= " if (obj) {\n";
$js .= " var i_max = obj.options.length;\n";
$js .= " for (var i=0; i<i_max; i++) {\n";
$js .= " obj.options[i].selected = truefalse;\n";
$js .= " }\n";
$js .= " }\n";
$js .= " return false;\n";
$js .= "}\n";
$js .= "//]]>\n";
$js .= "</script>\n";
$elements[] = $mform->createElement('static', '', '', $js);
}
$params = array('size' => 2);
$elements[] = $mform->createElement('text', $config_name, '', $params);
$elements[] = $mform->createElement('static', '', '', $static);
$mform->addGroup($elements, $elements_name, get_string($name, $plugin), ' ', false);
$mform->setType($config_name, PARAM_TEXT);
}
示例14: setup_table_type_row
/**
* Setup a table row
*
* @param object $mform The moodle form
* @param int $type The datatype of the rows
* @param array $dataset The row data
* @param bool $extrarow Whether an extra row should be added.
* @uses $CFG
* @uses $OUTPUT
*/
protected function setup_table_type_row($mform, $type, $dataset = array(), $extrarow)
{
global $CFG, $OUTPUT;
$typename = $this->types[$type];
$deletescoretype = get_string('results_delete_score', self::LANG_FILE);
$notypeselected = get_string("results_no_{$typename}_selected", self::LANG_FILE);
$selecttype = get_string("results_select_{$typename}", self::LANG_FILE);
$setdefault = false;
$prefix = $typename . '_';
$cache = 0;
$defaults = array();
$configs = array();
if ($extrarow) {
$empty_record = new stdClass();
$empty_record->min = '';
$empty_record->max = '';
$empty_record->selected = '';
$empty_record->value = '';
array_push($dataset, $empty_record);
$cache = 1;
}
$i = 0;
foreach ($dataset as $data) {
//error checking
if (!isset($data->min, $data->max)) {
continue;
}
// Start a table row and column
$tablehtml = html_writer::start_tag('tr');
$tablehtml .= html_writer::start_tag('td', array('style' => 'text-align:center;'));
$mform->addElement('html', $tablehtml);
$group = array();
// Add minimum field
$attributes = array('size' => 8, 'maxlength' => 8, 'value' => $data->min);
if (!(array_key_exists('active', $this->_customdata) && $this->_customdata['active'])) {
$attributes['disabled'] = 'disabled';
}
$group[] = $mform->createElement('text', "{$prefix}{$i}_min", '', $attributes);
// Add maximum field
$attributes['value'] = $data->max;
$group[] = $mform->createElement('text', "{$prefix}{$i}_max", '', $attributes);
// Add link and icon (Delete link).
$attributes = array('title' => $deletescoretype, 'alt' => $deletescoretype, 'class' => 'elisicon-remove elisiconcolored', 'onclick' => $this->prefixes[$type] . '_object.deleteRow(this); return false;');
$group[] = $mform->createElement('link', 'delete', '', "#", '', $attributes);
// Add minimum, maximum and delete to field group
$mform->addGroup($group, "{$prefix}{$i}_score", '', '', false);
$mform->setType("{$prefix}{$i}_min", PARAM_TEXT);
$mform->setType("{$prefix}{$i}_max", PARAM_TEXT);
$tablehtml = html_writer::end_tag('td');
$tablehtml .= html_writer::start_tag('td', array('style' => 'text-align:center;'));
$mform->addElement('html', $tablehtml);
if ($this->rowtypes[$type] == 'picklist') {
$name = '';
if (!empty($data->selected)) {
$name = $this->get_label_name($typename, $data->selected);
} else {
$name = $notypeselected;
}
// Need to add 2 hidden elements - 1 for Moodle forms and 1 For dynamic table.
$mform->addElement('hidden', "{$prefix}{$i}_selected", $data->selected);
$mform->setType("{$prefix}{$i}_selected", PARAM_TEXT);
$attributes = array('id' => "{$prefix}{$i}_label");
$attributes = array('size' => 20, 'value' => $name, 'disabled' => 'disabled');
$attributes = array('id' => "id_{$prefix}{$i}_label", 'value' => $name, 'name' => "{$prefix}{$i}_label", 'type' => 'text');
if (!(array_key_exists('active', $this->_customdata) && $this->_customdata['active'])) {
$attributes['disabled'] = 'disabled';
}
$output = html_writer::empty_tag('input', $attributes);
$attributes = array('id' => "id_{$prefix}{$i}_selected", 'value' => $data->selected, 'name' => "{$prefix}{$i}_selected", 'type' => 'hidden');
$output .= html_writer::empty_tag('input', $attributes);
$url = "{$typename}selector.php?id=id_{$prefix}{$i}_&callback=add_selection";
$attributes = array('name' => 'typeselector');
$output .= html_writer::link('#', $selecttype, $attributes);
$output .= html_writer::end_tag('td');
$output .= html_writer::start_tag('td');
$mform->addElement('html', $output);
} else {
if ($this->rowtypes[$type] == 'doubleselect') {
$options = $this->get_profile_fields();
$attributes = array();
if (!(array_key_exists('active', $this->_customdata) && $this->_customdata['active'])) {
$attributes = array('disabled' => 'disabled');
}
$url = $CFG->wwwroot . '/local/elisprogram/resultsprofileselect.php';
$frame = "{$prefix}{$i}_frame";
$value = "{$prefix}{$i}_value";
$attributes['onchange'] = "replace_content(\"{$url}\",\"{$frame}\",this.value,\"{$value}\");";
$mform->addElement('select', "{$prefix}{$i}_selected", '', $options, $attributes);
$attributes = array();
if (!(array_key_exists('active', $this->_customdata) && $this->_customdata['active'])) {
//.........这里部分代码省略.........
示例15: buildCommunicationBlock
/**
* Create communication preferences block for the contact.
*
* @param object $form - CRM_Core_Form (or it's subclass)
* @return none
*
* @access public
* @static
*/
function buildCommunicationBlock(&$form)
{
// since the pcm - preferred comminication method is logically
// grouped hence we'll use groups of HTML_QuickForm
$privacy = array();
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
$form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// preferred communication method
$form->add('select', 'preferred_communication_method', ts('Prefers'), CRM_Core_SelectValues::pcm());
$form->add('select', 'preferred_mail_format', ts('Mail Format'), CRM_Core_SelectValues::pmf());
}