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


PHP MoodleQuickForm::addGroupRule方法代碼示例

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


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

示例1: get_settings

 /**
  * Get the settings for onlinetext submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultwordlimit = $this->get_config('wordlimit') == 0 ? '' : $this->get_config('wordlimit');
     $defaultwordlimitenabled = $this->get_config('wordlimitenabled');
     $options = array('size' => '6', 'maxlength' => '6');
     $name = get_string('wordlimit', 'assignsubmission_onlinetext');
     // Create a text box that can be enabled/disabled for onlinetext word limit.
     $wordlimitgrp = array();
     $wordlimitgrp[] = $mform->createElement('text', 'assignsubmission_onlinetext_wordlimit', '', $options);
     $wordlimitgrp[] = $mform->createElement('checkbox', 'assignsubmission_onlinetext_wordlimit_enabled', '', get_string('enable'));
     $mform->addGroup($wordlimitgrp, 'assignsubmission_onlinetext_wordlimit_group', $name, ' ', false);
     $mform->addHelpButton('assignsubmission_onlinetext_wordlimit_group', 'wordlimit', 'assignsubmission_onlinetext');
     $mform->disabledIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_wordlimit_enabled', 'notchecked');
     // Add numeric rule to text field.
     $wordlimitgrprules = array();
     $wordlimitgrprules['assignsubmission_onlinetext_wordlimit'][] = array(null, 'numeric', null, 'client');
     $mform->addGroupRule('assignsubmission_onlinetext_wordlimit_group', $wordlimitgrprules);
     // Rest of group setup.
     $mform->setDefault('assignsubmission_onlinetext_wordlimit', $defaultwordlimit);
     $mform->setDefault('assignsubmission_onlinetext_wordlimit_enabled', $defaultwordlimitenabled);
     $mform->setType('assignsubmission_onlinetext_wordlimit', PARAM_INT);
     $mform->disabledIf('assignsubmission_onlinetext_wordlimit_group', 'assignsubmission_onlinetext_enabled', 'notchecked');
 }
開發者ID:qanuj,項目名稱:moodle,代碼行數:30,代碼來源:locallib.php


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