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


PHP moodleform::setDefault方法代码示例

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


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

示例1: define_form_specific

 /**
  * Add elements for creating/editing a text profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Default data.
     $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
     $form->setType('defaultdata', PARAM_TEXT);
     // Param 1 for text type is the size of the field.
     $form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
     $form->setDefault('param1', 30);
     $form->setType('param1', PARAM_INT);
     // Param 2 for text type is the maxlength of the field.
     $form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
     $form->setDefault('param2', 2048);
     $form->setType('param2', PARAM_INT);
     // Param 3 for text type detemines if this is a password field or not.
     $form->addElement('selectyesno', 'param3', get_string('profilefieldispassword', 'admin'));
     $form->setDefault('param3', 0);
     // Defaults to 'no'.
     $form->setType('param3', PARAM_INT);
     // Param 4 for text type contains a link.
     $form->addElement('text', 'param4', get_string('profilefieldlink', 'admin'));
     $form->setType('param4', PARAM_URL);
     $form->addHelpButton('param4', 'profilefieldlink', 'admin');
     // Param 5 for text type contains link target.
     $targetoptions = array('' => get_string('linktargetnone', 'editor'), '_blank' => get_string('linktargetblank', 'editor'), '_self' => get_string('linktargetself', 'editor'), '_top' => get_string('linktargettop', 'editor'));
     $form->addElement('select', 'param5', get_string('profilefieldlinktarget', 'admin'), $targetoptions);
     $form->setType('param5', PARAM_RAW);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:define.class.php

示例2: 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);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:38,代码来源:define.class.php

示例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);
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:16,代码来源:edit_form.php

示例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);
     }
 }
开发者ID:nmicha,项目名称:moodle,代码行数:18,代码来源:completion_criteria_date.php

示例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);
     }
 }
开发者ID:nmicha,项目名称:moodle,代码行数:20,代码来源:completion_criteria_duration.php

示例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_self', get_string('enable'));
     if ($this->id) {
         $mform->setDefault('criteria_self', 1);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:13,代码来源:completion_criteria_self.php

示例7: 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);
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:13,代码来源:completion_criteria_unenrol.php

示例8: 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);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:completion_criteria_role.php

示例9: 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);
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:13,代码来源:completion_criteria_activity.php

示例10:

 /**
  * 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);
 }
开发者ID:dariogs,项目名称:moosh,代码行数:14,代码来源:define.class.php

示例11: 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);
     }
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:14,代码来源:completion_criteria_activity.php

示例12: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs[] = $mform->createElement('select', $this->_name, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:select.php

示例13: 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'));
     // Populate the duration length drop down.
     $thresholdmenu = array(86400 => get_string('secondstotime86400', 'core'), 172800 => get_string('secondstotime172800', 'core'), 259200 => get_string('secondstotime259200', 'core'), 345600 => get_string('secondstotime345600', 'core'), 432000 => get_string('secondstotime432000', 'core'), 518400 => get_string('secondstotime518400', 'core'), 518400 => get_string('secondstotime518400', 'core'));
     // Append strings for 7 - 30 days (step by 1 day).
     for ($i = 7; $i <= 30; $i++) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append strings for 40 - 180 days (step by 10 days).
     for ($i = 40; $i <= 180; $i = $i + 10) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append string for 1 year.
     $thresholdmenu[365 * DAYSECS] = get_string('numdays', 'core', 365);
     $mform->addElement('select', 'criteria_duration_days', get_string('enrolmentdurationlength', 'core_completion'), $thresholdmenu);
     $mform->disabledIf('criteria_duration_days', 'criteria_duration');
     if ($this->id) {
         $mform->setDefault('criteria_duration', 1);
         $mform->setDefault('criteria_duration_days', $this->enrolperiod);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:completion_criteria_duration.php

示例14: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs['limiter'] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs['limiter']->setLabel(get_string('limiterfor', 'filters', $this->_label));
     $objs['country'] = $mform->createElement('select', $this->_name, null, $this->_options);
     $objs['country']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:20,代码来源:select.php

示例15: edit_field_add

 /**
  * Handles editing datetime fields.
  *
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Check if the field is required.
     if ($this->field->required) {
         $optional = false;
     } else {
         $optional = true;
     }
     // Convert the year stored in the DB as gregorian to that used by the calendar type.
     $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1);
     $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1);
     $attributes = array('startyear' => $startdate['year'], 'stopyear' => $stopdate['year'], 'optional' => $optional);
     // Check if they wanted to include time as well.
     if (!empty($this->field->param3)) {
         $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes);
     } else {
         $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes);
     }
     $mform->setType($this->inputname, PARAM_INT);
     $mform->setDefault($this->inputname, time());
 }
开发者ID:janeklb,项目名称:moodle,代码行数:28,代码来源:field.class.php


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