本文整理汇总了PHP中moodleform::addElement方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform::addElement方法的具体用法?PHP moodleform::addElement怎么用?PHP moodleform::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodleform
的用法示例。
在下文中一共展示了moodleform::addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define_form_specific
/**
* Define the setting for a datetime custom field.
*
* @param moodleform $form the user form
*/
public function define_form_specific($form)
{
// Get the current calendar in use - see MDL-18375.
$calendartype = \core_calendar\type_factory::get_calendar_instance();
// Create variables to store start and end.
list($year, $month, $day) = explode('_', date('Y_m_d'));
$currentdate = $calendartype->convert_from_gregorian($year, $month, $day);
$currentyear = $currentdate['year'];
$arryears = $calendartype->get_years();
// Add elements.
$form->addElement('select', 'param1', get_string('startyear', 'profilefield_datetime'), $arryears);
$form->setType('param1', PARAM_INT);
$form->setDefault('param1', $currentyear);
$form->addElement('select', 'param2', get_string('endyear', 'profilefield_datetime'), $arryears);
$form->setType('param2', PARAM_INT);
$form->setDefault('param2', $currentyear);
$form->addElement('checkbox', 'param3', get_string('wanttime', 'profilefield_datetime'));
$form->setType('param3', PARAM_INT);
$form->addElement('hidden', 'startday', '1');
$form->setType('startday', PARAM_INT);
$form->addElement('hidden', 'startmonth', '1');
$form->setType('startmonth', PARAM_INT);
$form->addElement('hidden', 'startyear', '1');
$form->setType('startyear', PARAM_INT);
$form->addElement('hidden', 'endday', '1');
$form->setType('endday', PARAM_INT);
$form->addElement('hidden', 'endmonth', '1');
$form->setType('endmonth', PARAM_INT);
$form->addElement('hidden', 'endyear', '1');
$form->setType('endyear', PARAM_INT);
$form->addElement('hidden', 'defaultdata', '0');
$form->setType('defaultdata', PARAM_INT);
}
示例2: define_form_specific
/**
* Adds elements to the form for creating/editing this type of profile field.
* @param moodleform $form
*/
public function define_form_specific($form)
{
// Param 1 for menu type contains the options.
$form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
$form->setType('param1', PARAM_TEXT);
// Default data.
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
$form->setType('defaultdata', PARAM_TEXT);
}
示例3: specific_definition
/**
* Form definition.
*
* @param moodleform $mform Moodle form.
* @return void
*/
protected function specific_definition($mform)
{
$mform->addElement('header', 'confighdr', get_string('configheader', 'block_xp'));
$mform->addElement('text', 'config_title', get_string('configtitle', 'block_xp'));
$mform->setDefault('config_title', get_string('levelup', 'block_xp'));
$mform->setType('config_title', PARAM_TEXT);
$mform->addElement('textarea', 'config_description', get_string('configdescription', 'block_xp'));
$mform->setDefault('config_description', get_string('participatetolevelup', 'block_xp'));
$mform->setType('config_description', PARAM_TEXT);
}
示例4: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data not used
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_date', get_string('enable'));
$mform->addElement('date_selector', 'criteria_date_value', get_string('afterspecifieddate', 'completion'));
// If instance of criteria exists
if ($this->id) {
$mform->setDefault('criteria_date', 1);
$mform->setDefault('criteria_date_value', $this->timeend);
} else {
$mform->setDefault('criteria_date_value', time() + 3600 * 24);
}
}
示例5: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data not used
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_duration', get_string('enable'));
$thresholdmenu = array();
for ($i = 1; $i <= 30; $i++) {
$seconds = $i * 86400;
$thresholdmenu[$seconds] = get_string('numdays', '', $i);
}
$mform->addElement('select', 'criteria_duration_days', get_string('daysafterenrolment', 'completion'), $thresholdmenu);
if ($this->id) {
$mform->setDefault('criteria_duration', 1);
$mform->setDefault('criteria_duration_days', $this->enrolperiod);
}
}
示例6: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data Form data
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_unenrol', get_string('completiononunenrolment', 'completion'));
if ($this->id) {
$mform->setDefault('criteria_unenrol', 1);
}
}
示例7: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data details of various modules
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', ucfirst(self::get_mod_name($data->module)) . ' - ' . $data->name);
if ($this->id) {
$mform->setDefault('criteria_activity[' . $data->id . ']', 1);
}
}
示例8: define_form_specific
/**
* Add elements for creating/editing a textarea profile field.
* @param moodleform $form
*/
public function define_form_specific($form)
{
// Default data.
$form->addElement('editor', 'defaultdata', get_string('profiledefaultdata', 'admin'));
$form->setType('defaultdata', PARAM_RAW);
// We have to trust person with capability to edit this default description.
}
示例9: edit_field_add
/**
* Adds elements for this field type to the edit form.
* @param moodleform $mform
*/
public function edit_field_add($mform)
{
// Create the form field.
$mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
$mform->setType($this->inputname, PARAM_RAW);
// We MUST clean this before display!
}
示例10: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data Form data
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_self', get_string('enable'));
if ($this->id) {
$mform->setDefault('criteria_self', 1);
}
}
示例11: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data used to set default values of the form
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_role[' . $data->id . ']', $this->get_title($data));
if ($this->id) {
$mform->setDefault('criteria_role[' . $data->id . ']', 1);
}
}
示例12: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data details of various modules
*/
public function config_form_display(&$mform, $data = null)
{
$modnames = get_module_types_names();
$mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', $modnames[self::get_mod_name($data->module)] . ' - ' . format_string($data->name));
if ($this->id) {
$mform->setDefault('criteria_activity[' . $data->id . ']', 1);
}
}
示例13: setupForm
/**
* Adds controls specific to this filter in the form.
* @param moodleform $mform a MoodleForm object to setup
*/
public function setupForm(&$mform)
{
$choices = array('' => get_string('anyvalue', 'filters')) + $this->_options;
$mform->addElement('select', $this->_name, $this->_label, $choices);
if ($this->_advanced) {
$mform->setAdvanced($this->_name);
}
}
示例14:
/**
* Prints out the form snippet for the part of creating or
* editing a profile field specific to the current data type
*
* @param moodleform $form reference to moodleform for adding elements.
*/
function define_form_specific(&$form)
{
//Add elements, set defualt value and define type of data
$form->addElement('radio', 'defaultdata', get_string('mystring', 'profilefield_myprofilefield'));
$form->setDefault('defaultdata', 1);
// defaults to 'yes'
$form->setType('defaultdata', PARAM_BOOL);
}
示例15: edit_field_add
/**
* Add elements for editing the profile field value.
* @param moodleform $mform
*/
public function edit_field_add($mform)
{
// Create the form field.
$checkbox = $mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
if ($this->data == '1') {
$checkbox->setChecked(true);
}
$mform->setType($this->inputname, PARAM_BOOL);
if ($this->is_required() and !has_capability('moodle/user:update', context_system::instance())) {
$mform->addRule($this->inputname, get_string('required'), 'nonzero', null, 'client');
}
}