本文整理汇总了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');
}