本文整理汇总了PHP中MoodleQuickForm::getElementValue方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::getElementValue方法的具体用法?PHP MoodleQuickForm::getElementValue怎么用?PHP MoodleQuickForm::getElementValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoodleQuickForm
的用法示例。
在下文中一共展示了MoodleQuickForm::getElementValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_edit_form_elements
/**
* Adds format options elements to the course/section edit form
*
* This function is called from {@link course_edit_form::definition_after_data()}
*
* @param MoodleQuickForm $mform form the elements are added to
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form
* @return array array of references to the added form elements
*/
public function create_edit_form_elements(&$mform, $forsection = false)
{
$elements = array();
if ($forsection) {
$options = $this->section_format_options(true);
} else {
$options = $this->course_format_options(true);
}
foreach ($options as $optionname => $option) {
if (!isset($option['element_type'])) {
$option['element_type'] = 'text';
}
$args = array($option['element_type'], $optionname, $option['label']);
if (!empty($option['element_attributes'])) {
$args = array_merge($args, $option['element_attributes']);
}
$elements[] = call_user_func_array(array($mform, 'addElement'), $args);
if (isset($option['help'])) {
$helpcomponent = 'format_' . $this->get_format();
if (isset($option['help_component'])) {
$helpcomponent = $option['help_component'];
}
$mform->addHelpButton($optionname, $option['help'], $helpcomponent);
}
if (isset($option['type'])) {
$mform->setType($optionname, $option['type']);
}
if (is_null($mform->getElementValue($optionname)) && isset($option['default'])) {
$mform->setDefault($optionname, $option['default']);
}
}
if (!$forsection && empty($this->courseid)) {
// At this stage (this is called from definition_after_data) course data is already set as default.
// We can not overwrite what is in the database.
$mform->setDefault('enddate', $this->get_default_course_enddate($mform));
}
return $elements;
}
示例2: create_edit_form_elements
/**
* Adds format options elements to the course/section edit form
*
* This function is called from {@link course_edit_form::definition_after_data()}
*
* @param MoodleQuickForm $mform form the elements are added to
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form
* @return array array of references to the added form elements
*/
public function create_edit_form_elements(&$mform, $forsection = false)
{
$elements = array();
if ($forsection) {
$options = $this->section_format_options(true);
} else {
$options = $this->course_format_options(true);
}
foreach ($options as $optionname => $option) {
if (!isset($option['element_type'])) {
$option['element_type'] = 'text';
}
$args = array($option['element_type'], $optionname, $option['label']);
if (!empty($option['element_attributes'])) {
$args = array_merge($args, $option['element_attributes']);
}
$elements[] = call_user_func_array(array($mform, 'addElement'), $args);
if (isset($option['help'])) {
$helpcomponent = 'format_' . $this->get_format();
if (isset($option['help_component'])) {
$helpcomponent = $option['help_component'];
}
$mform->addHelpButton($optionname, $option['help'], $helpcomponent);
}
if (isset($option['type'])) {
$mform->setType($optionname, $option['type']);
}
if (is_null($mform->getElementValue($optionname)) && isset($option['default'])) {
$mform->setDefault($optionname, $option['default']);
}
}
return $elements;
}