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


PHP moodleform::getElement方法代碼示例

本文整理匯總了PHP中moodleform::getElement方法的典型用法代碼示例。如果您正苦於以下問題:PHP moodleform::getElement方法的具體用法?PHP moodleform::getElement怎麽用?PHP moodleform::getElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moodleform的用法示例。


在下文中一共展示了moodleform::getElement方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_form_start_date

 /**
  * Get the start date value from the course settings page form.
  *
  * @param moodleform $mform
  * @param array $fieldnames The form - field names mapping.
  * @return int
  */
 protected function get_form_start_date($mform, $fieldnames)
 {
     $startdate = $mform->getElementValue($fieldnames['startdate']);
     return $mform->getElement($fieldnames['startdate'])->exportValue($startdate);
 }
開發者ID:EsdrasCaleb,項目名稱:moodle,代碼行數:12,代碼來源:lib.php

示例2: define_after_data

 /**
  * Alter form based on submitted or existing data.
  *
  * @param moodleform $mform
  */
 public function define_after_data(&$mform)
 {
     global $DB;
     // If we are adding a new profile field then the dates have already been set
     // by setDefault to the correct dates in the used calendar system. We only want
     // to execute the rest of the code when we have the years in the DB saved in
     // Gregorian that need converting to the date for this user.
     $id = required_param('id', PARAM_INT);
     if ($id === 0) {
         return;
     }
     // Get the field data from the DB.
     $field = $DB->get_record('user_info_field', array('id' => $id), 'param1, param2', MUST_EXIST);
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // An array to store form values.
     $values = array();
     // The start and end year will be set as a Gregorian year in the DB. We want
     // convert these to the equivalent year in the current calendar type being used.
     $startdate = $calendartype->convert_from_gregorian($field->param1, 1, 1);
     $values['startday'] = $startdate['day'];
     $values['startmonth'] = $startdate['month'];
     $values['startyear'] = $startdate['year'];
     $values['param1'] = $startdate['year'];
     $stopdate = $calendartype->convert_from_gregorian($field->param2, 1, 1);
     $values['endday'] = $stopdate['day'];
     $values['endmonth'] = $stopdate['month'];
     $values['endyear'] = $stopdate['year'];
     $values['param2'] = $stopdate['year'];
     // Set the values.
     foreach ($values as $key => $value) {
         $param = $mform->getElement($key);
         $param->setValue($value);
     }
 }
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:40,代碼來源:define.class.php


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