当前位置: 首页>>代码示例>>PHP>>正文


PHP moodleform::disabledIf方法代码示例

本文整理汇总了PHP中moodleform::disabledIf方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform::disabledIf方法的具体用法?PHP moodleform::disabledIf怎么用?PHP moodleform::disabledIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodleform的用法示例。


在下文中一共展示了moodleform::disabledIf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupForm

 /**
  * Adds controls specific to this filter in the form.
  *
  * @param moodleform $mform a MoodleQuickForm object in which element will be added
  */
 public function setupForm(&$mform)
 {
     $mform->addElement('checkbox', $this->_name, $this->_label, '');
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name);
     }
     // Check if disable if options are set. if yes then set rules.
     if (!empty($this->disableelements) && is_array($this->disableelements)) {
         foreach ($this->disableelements as $disableelement) {
             $mform->disabledIf($disableelement, $this->_name, 'checked');
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:checkbox.php

示例2: 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('completionondatevalue', 'core_completion'));
     $mform->disabledIf('criteria_date_value', 'criteria_date');
     // 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:janaece,项目名称:globalclassroom4_clean,代码行数:19,代码来源:completion_criteria_date.php

示例3: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs[] = $mform->createElement('select', $this->_name, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:select.php

示例4: setupForm

 /**
  * Adds controls specific to this filter in the form.
  *
  * @param moodleform $mform a MoodleQuickForm object in which element will be added
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('checkbox', $this->_name, null, '');
     $grp = $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
     // Check if disable if options are set. if yes then set rules.
     if (!empty($this->disableelements) && is_array($this->disableelements)) {
         foreach ($this->disableelements as $disableelement) {
             $mform->disabledIf($disableelement, $this->_name, 'checked');
         }
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:checkbox.php

示例5: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs['limiter'] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs['limiter']->setLabel(get_string('limiterfor', 'filters', $this->_label));
     $objs['country'] = $mform->createElement('select', $this->_name, null, $this->_options);
     $objs['country']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:20,代码来源:select.php

示例6: 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'));
     // Populate the duration length drop down.
     $thresholdmenu = array(86400 => get_string('secondstotime86400', 'core'), 172800 => get_string('secondstotime172800', 'core'), 259200 => get_string('secondstotime259200', 'core'), 345600 => get_string('secondstotime345600', 'core'), 432000 => get_string('secondstotime432000', 'core'), 518400 => get_string('secondstotime518400', 'core'), 518400 => get_string('secondstotime518400', 'core'));
     // Append strings for 7 - 30 days (step by 1 day).
     for ($i = 7; $i <= 30; $i++) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append strings for 40 - 180 days (step by 10 days).
     for ($i = 40; $i <= 180; $i = $i + 10) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append string for 1 year.
     $thresholdmenu[365 * DAYSECS] = get_string('numdays', 'core', 365);
     $mform->addElement('select', 'criteria_duration_days', get_string('enrolmentdurationlength', 'core_completion'), $thresholdmenu);
     $mform->disabledIf('criteria_duration_days', 'criteria_duration');
     if ($this->id) {
         $mform->setDefault('criteria_duration', 1);
         $mform->setDefault('criteria_duration_days', $this->enrolperiod);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:completion_criteria_duration.php

示例7: onQuickFormEvent

 /**
  * Called by HTML_QuickForm whenever form event is made on this element.
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param moodleform $caller calling object
  * @return mixed
  */
 public function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'createElement':
             // The first argument is the name.
             $name = $arg[0];
             // Set disable actions.
             $caller->disabledIf($name . '[modgrade_scale]', $name . '[modgrade_type]', 'neq', 'scale');
             $caller->disabledIf($name . '[modgrade_point]', $name . '[modgrade_type]', 'neq', 'point');
             // Set validation rules for the sub-elements belonging to this element.
             // A handy note: the parent scope of a closure is the function in which the closure was declared.
             // Because of this using $this is safe despite the closures being called statically.
             // A nasty magic hack!
             $checkmaxgrade = function ($val) {
                 // Closure to validate a max points value. See the note above about scope if this confuses you.
                 if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') {
                     if (!isset($val['modgrade_point'])) {
                         return false;
                     }
                     return $this->validate_point($val['modgrade_point']);
                 }
                 return true;
             };
             $checkvalidscale = function ($val) {
                 // Closure to validate a scale value. See the note above about scope if this confuses you.
                 if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'scale') {
                     if (!isset($val['modgrade_scale'])) {
                         return false;
                     }
                     return $this->validate_scale($val['modgrade_scale']);
                 }
                 return true;
             };
             $maxgradeexceeded = get_string('modgradeerrorbadpoint', 'grades', get_config('core', 'gradepointmax'));
             $invalidscale = get_string('modgradeerrorbadscale', 'grades');
             // When creating the rules the sixth arg is $force, we set it to true because otherwise the form
             // will attempt to validate the existence of the element, we don't want this because the element
             // is being created right now and doesn't actually exist as a registered element yet.
             $caller->addRule($name, $maxgradeexceeded, 'callback', $checkmaxgrade, 'server', false, true);
             $caller->addRule($name, $invalidscale, 'callback', $checkvalidscale, 'server', false, true);
             break;
         case 'updateValue':
             // As this is a group element with no value of its own we are only interested in situations where the
             // default value or a constant value are being provided to the actual element.
             // In this case we expect an int that is going to translate to a scale if negative, or to max points
             // if positive.
             // A constant value should be given as an int.
             // The default value should be an int and should really be $CFG->gradepointdefault.
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 if ($caller->isSubmitted()) {
                     break;
                 }
                 $value = $this->_findValue($caller->_defaultValues);
             }
             if (!is_null($value) && !is_scalar($value)) {
                 // Something unexpected (likely an array of subelement values) has been given - this will be dealt
                 // with somewhere else - where exactly... likely the subelements.
                 debugging('An invalid value (type ' . gettype($value) . ') has arrived at ' . __METHOD__, DEBUG_DEVELOPER);
                 break;
             }
             // Set element state for existing data.
             // This is really a pretty hacky thing to do, when data is being set the group element is called
             // with the data first and the subelements called afterwards.
             // This means that the subelements data (inc const and default values) can be overridden by form code.
             // So - when we call this code really we can't be sure that will be the end value for the element.
             if (!empty($this->_elements)) {
                 if (!empty($value)) {
                     if ($value < 0) {
                         $this->_elements[1]->setValue('scale');
                         $this->_elements[4]->setValue($value * -1);
                     } else {
                         if ($value > 0) {
                             $this->_elements[1]->setValue('point');
                             $this->_elements[7]->setValue($value);
                         }
                     }
                 } else {
                     $this->_elements[1]->setValue('none');
                     $this->_elements[7]->setValue('');
                 }
             }
             break;
     }
     // Always let the parent do its thing!
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:95,代码来源:modgrade.php

示例8: onQuickFormEvent

 /**
  * Called by HTML_QuickForm whenever form event is made on this element.
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param moodleform $caller calling object
  * @return mixed
  */
 public function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'createElement':
             // The first argument is the name.
             $name = $arg[0];
             // Set disable actions.
             $caller->disabledIf($name . '[modgrade_scale]', $name . '[modgrade_type]', 'neq', 'scale');
             $caller->disabledIf($name . '[modgrade_point]', $name . '[modgrade_type]', 'neq', 'point');
             $caller->disabledIf($name . '[modgrade_rescalegrades]', $name . '[modgrade_type]', 'neq', 'point');
             // Set validation rules for the sub-elements belonging to this element.
             // A handy note: the parent scope of a closure is the function in which the closure was declared.
             // Because of this using $this is safe despite the closures being called statically.
             // A nasty magic hack!
             $checkgradetypechange = function ($val) {
                 // Nothing is affected by changes to the grade type if there are no grades yet.
                 if (!$this->hasgrades) {
                     return true;
                 }
                 // Check if we are changing the grade type when grades are present.
                 if (isset($val['modgrade_type']) && $val['modgrade_type'] !== $this->currentgradetype) {
                     return false;
                 }
                 return true;
             };
             $checkscalechange = function ($val) {
                 // Nothing is affected by changes to the scale if there are no grades yet.
                 if (!$this->hasgrades) {
                     return true;
                 }
                 // Check if we are changing the scale type when grades are present.
                 // If modgrade_type is empty then use currentgradetype.
                 $gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
                 if ($gradetype === 'scale') {
                     if (isset($val['modgrade_scale']) && $val['modgrade_scale'] !== $this->currentscaleid) {
                         return false;
                     }
                 }
                 return true;
             };
             $checkmaxgradechange = function ($val) {
                 // Nothing is affected by changes to the max grade if there are no grades yet.
                 if (!$this->hasgrades) {
                     return true;
                 }
                 // If we are not using ratings we can change the max grade.
                 if (!$this->useratings) {
                     return true;
                 }
                 // Check if we are changing the max grade if we are using ratings and there is a grade.
                 // If modgrade_type is empty then use currentgradetype.
                 $gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
                 if ($gradetype === 'point') {
                     if (isset($val['modgrade_point']) && grade_floats_different($this->currentgrade, $val['modgrade_point'])) {
                         return false;
                     }
                 }
                 return true;
             };
             $checkmaxgrade = function ($val) {
                 // Closure to validate a max points value. See the note above about scope if this confuses you.
                 // If modgrade_type is empty then use currentgradetype.
                 $gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
                 if ($gradetype === 'point') {
                     if (isset($val['modgrade_point'])) {
                         return $this->validate_point($val['modgrade_point']);
                     }
                 }
                 return true;
             };
             $checkvalidscale = function ($val) {
                 // Closure to validate a scale value. See the note above about scope if this confuses you.
                 // If modgrade_type is empty then use currentgradetype.
                 $gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
                 if ($gradetype === 'scale') {
                     if (isset($val['modgrade_scale'])) {
                         return $this->validate_scale($val['modgrade_scale']);
                     }
                 }
                 return true;
             };
             $checkrescale = function ($val) {
                 // Nothing is affected by changes to grademax if there are no grades yet.
                 if (!$this->isupdate || !$this->hasgrades || !$this->canrescale) {
                     return true;
                 }
                 // Closure to validate a scale value. See the note above about scope if this confuses you.
                 // If modgrade_type is empty then use currentgradetype.
                 $gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
                 if ($gradetype === 'point' && isset($val['modgrade_point'])) {
                     // Work out if the value was actually changed in the form.
                     if (grade_floats_different($this->currentgrade, $val['modgrade_point'])) {
//.........这里部分代码省略.........
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:101,代码来源:modgrade.php


注:本文中的moodleform::disabledIf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。