當前位置: 首頁>>代碼示例>>PHP>>正文


PHP moodleform::addElement方法代碼示例

本文整理匯總了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);
 }
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:38,代碼來源:define.class.php

示例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);
 }
開發者ID:krysnuvadga,項目名稱:moodle,代碼行數:13,代碼來源: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_unenrol', get_string('completiononunenrolment', 'completion'));
     if ($this->id) {
         $mform->setDefault('criteria_unenrol', 1);
     }
 }
開發者ID:JP-Git,項目名稱:moodle,代碼行數:13,代碼來源:completion_criteria_unenrol.php

示例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);
     }
 }
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:13,代碼來源:completion_criteria_activity.php

示例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.
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:11,代碼來源:define.class.php

示例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!
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:11,代碼來源:field.class.php

示例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);
     }
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:13,代碼來源:completion_criteria_self.php

示例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);
     }
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:13,代碼來源:completion_criteria_role.php

示例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);
     }
 }
開發者ID:Gavinthisisit,項目名稱:Moodle,代碼行數:14,代碼來源:completion_criteria_activity.php

示例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);
     }
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:12,代碼來源:simpleselect.php

示例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);
 }
開發者ID:dariogs,項目名稱:moosh,代碼行數:14,代碼來源:define.class.php

示例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');
     }
 }
開發者ID:janeklb,項目名稱:moodle,代碼行數:16,代碼來源:field.class.php


注:本文中的moodleform::addElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。