Add the step configuration to the form.

@param   MoodleQuickForm $mform      The form to add configuration to.
@return  $this
976844
public function add_config_to_form(\MoodleQuickForm &$mform) {
        $options = configuration::get_placement_options();
        $mform->addElement('select', 'placement', get_string('placement', 'tool_usertours'), $options);
        $mform->addHelpButton('placement', 'placement', 'tool_usertours');

        $this->add_config_field_to_form($mform, 'orphan');
        $this->add_config_field_to_form($mform, 'backdrop');
        $this->add_config_field_to_form($mform, 'reflex');

        return $this;
    }
571493
public function get_options(&$mform) {
        $none = true;
        $existing = array();
        $missing = array();

        $course = $this->course;
        $info = new completion_info($course);
        $mods = $info->get_activities();
        $mids = array_keys($mods);

        if ($this->id !== 0) {
            $existing = array_keys($this->params);
            $missing = array_diff($existing, $mids);
        }

        if (!empty($missing)) {
            $mform->addElement('header', 'category_errors', get_string('criterror', 'badges'));
            $mform->addHelpButton('category_errors', 'criterror', 'badges');
            foreach ($missing as $m) {
                $this->config_options($mform, array('id' => $m, 'checked' => true,
                        'name' => get_string('error:nosuchmod', 'badges'), 'error' => true));
                $none = false;
            }
        }

        if (!empty($mods)) {
            $mform->addElement('header', 'first_header', $this->get_title());
            foreach ($mods as $mod) {
                $checked = false;
                if (in_array($mod->id, $existing)) {
                    $checked = true;
                }
                $param = array('id' => $mod->id,
                        'checked' => $checked,
                        'name' => get_string('modulename', $mod->modname) . ' - ' . $mod->name,
                        'error' => false
                        );

                if ($this->id !== 0 && isset($this->params[$mod->id]['bydate'])) {
                    $param['bydate'] = $this->params[$mod->id]['bydate'];
                }

                if ($this->id !== 0 && isset($this->params[$mod->id]['grade'])) {
                    $param['grade'] = $this->params[$mod->id]['grade'];
                }

                $this->config_options($mform, $param);
                $none = false;
            }
        }

        // Add aggregation.
        if (!$none) {
            $mform->addElement('header', 'aggregation', get_string('method', 'badges'));
            $agg = array();
            $agg[] =& $mform->createElement('radio', 'agg', '', get_string('allmethodactivity', 'badges'), 1);
            $agg[] =& $mform->createElement('radio', 'agg', '', get_string('anymethodactivity', 'badges'), 2);
            $mform->addGroup($agg, 'methodgr', '', array('<br/>'), false);
            if ($this->id !== 0) {
                $mform->setDefault('agg', $this->method);
            } else {
                $mform->setDefault('agg', BADGE_CRITERIA_AGGREGATION_ANY);
            }
        }

        return array($none, get_string('error:noactivities', 'badges'));
    }
132668
public function config_form_definition(\MoodleQuickForm $mform) {
        $mform->addElement('header', 'header_specificsettings', get_string('specificsettings', 'customfield_checkbox'));
        $mform->setExpanded('header_specificsettings', true);

        $mform->addElement('selectyesno', 'configdata[checkbydefault]', get_string('checkedbydefault', 'customfield_checkbox'));
        $mform->setType('configdata[checkbydefault]', PARAM_BOOL);
    }
660756
public function edit_field_set_default($mform) {
        $key = $this->field->defaultdata;
        if (isset($this->options[$key]) || ($key = array_search($key, $this->options)) !== false){
            $defaultkey = $key;
        } else {
            $defaultkey = '';
        }
        $mform->setDefault($this->inputname, $defaultkey);
    }
858872
public function edit_field($mform) {
        if (!$this->is_editable()) {
            return false;
        }

        $this->edit_field_add($mform);
        $this->edit_field_set_default($mform);
        $this->edit_field_set_required($mform);
        return true;
    }
669249
public static function type_config_form($mform, $classname = 'repository') {
        parent::type_config_form($mform, $classname);
        $apikey = get_config('youtube', 'apikey');
        if (empty($apikey)) {
            $apikey = '';
        }

        $mform->addElement('text', 'apikey', get_string('apikey', 'repository_youtube'), array('value' => $apikey, 'size' => '40'));
        $mform->setType('apikey', PARAM_RAW_TRIMMED);
        $mform->addRule('apikey', get_string('required'), 'required', null, 'client');

        $mform->addElement('static', null, '',  get_string('information', 'repository_youtube'));
    }
212964
public function edit_field_set_required($mform) {
        global $USER;
        if ($this->is_required() && ($this->userid == $USER->id || isguestuser())) {
            $mform->addRule($this->inputname, get_string('required'), 'required', null, 'client');
        }
    }
1366703
protected function definition_answer_choice(&$mform) {
        $mform->addElement('header', 'choicehdr', get_string('choices', 'qtype_gapselect'));
        $mform->setExpanded('choicehdr', 1);

        $mform->addElement('checkbox', 'shuffleanswers', get_string('shuffle', 'qtype_gapselect'));
        $mform->setDefault('shuffleanswers', 0);

        $textboxgroup = array();
        $textboxgroup[] = $mform->createElement('group', 'choices',
                get_string('choicex', 'qtype_gapselect'), $this->choice_group($mform));

        if (isset($this->question->options)) {
            $countanswers = count($this->question->options->answers);
        } else {
            $countanswers = 0;
        }

        if ($this->question->formoptions->repeatelements) {
            $defaultstartnumbers = QUESTION_NUMANS_START * 2;
            $repeatsatstart = max($defaultstartnumbers, QUESTION_NUMANS_START,
                    $countanswers + QUESTION_NUMANS_ADD);
        } else {
            $repeatsatstart = $countanswers;
        }

        $repeatedoptions = $this->repeated_options();
        $mform->setType('answer', PARAM_RAW);
        $this->repeat_elements($textboxgroup, $repeatsatstart, $repeatedoptions,
                'noanswers', 'addanswers', QUESTION_NUMANS_ADD,
                get_string('addmorechoiceblanks', 'qtype_gapselect'), true);
    }
1227281
public static function type_config_form($mform, $classname = 'repository') {
        global $OUTPUT;

        $url = new moodle_url('/admin/tool/oauth2/issuers.php');
        $url = $url->out();

        $mform->addElement('static', null, '', get_string('oauth2serviceslink', 'repository_onedrive', $url));

        if (self::can_import_skydrive_files()) {
            $notice = get_string('skydrivefilesexist', 'repository_onedrive');
            $url = new moodle_url('/repository/onedrive/importskydrive.php');
            $attrs = ['class' => 'btn btn-primary'];
            $button = $OUTPUT->action_link($url, get_string('importskydrivefiles', 'repository_onedrive'), null, $attrs);
            $mform->addElement('static', null, '', $OUTPUT->notification($notice) . $button);
        }

        parent::type_config_form($mform);
        $options = [];
        $issuers = \core\oauth2\api::get_all_issuers();

        foreach ($issuers as $issuer) {
            $options[$issuer->get('id')] = s($issuer->get('name'));
        }

        $strrequired = get_string('required');

        $mform->addElement('select', 'issuerid', get_string('issuer', 'repository_onedrive'), $options);
        $mform->addHelpButton('issuerid', 'issuer', 'repository_onedrive');
        $mform->addRule('issuerid', $strrequired, 'required', null, 'client');

        $mform->addElement('static', null, '', get_string('fileoptions', 'repository_onedrive'));
        $choices = [
            'internal' => get_string('internal', 'repository_onedrive'),
            'external' => get_string('external', 'repository_onedrive'),
            'both' => get_string('both', 'repository_onedrive')
        ];
        $mform->addElement('select', 'supportedreturntypes', get_string('supportedreturntypes', 'repository_onedrive'), $choices);

        $choices = [
            FILE_INTERNAL => get_string('internal', 'repository_onedrive'),
            FILE_CONTROLLED_LINK => get_string('external', 'repository_onedrive'),
        ];
        $mform->addElement('select', 'defaultreturntype', get_string('defaultreturntype', 'repository_onedrive'), $choices);

    }
259822
protected function add_unit_options($mform) {

        $mform->addElement('header', 'unithandling',
                get_string('unithandling', 'qtype_numerical'));

        $unitoptions = array(
            qtype_numerical::UNITNONE     => get_string('onlynumerical', 'qtype_numerical'),
            qtype_numerical::UNITOPTIONAL => get_string('manynumerical', 'qtype_numerical'),
            qtype_numerical::UNITGRADED   => get_string('unitgraded', 'qtype_numerical'),
        );
        $mform->addElement('select', 'unitrole',
                get_string('unithandling', 'qtype_numerical'), $unitoptions);

        $penaltygrp = array();
        $penaltygrp[] = $mform->createElement('float', 'unitpenalty',
                get_string('unitpenalty', 'qtype_numerical'), array('size' => 6));
        $mform->setDefault('unitpenalty', 0.1000000);

        $unitgradingtypes = array(
            qtype_numerical::UNITGRADEDOUTOFMARK =>
                    get_string('decfractionofresponsegrade', 'qtype_numerical'),
            qtype_numerical::UNITGRADEDOUTOFMAX =>
                    get_string('decfractionofquestiongrade', 'qtype_numerical'),
        );
        $penaltygrp[] = $mform->createElement('select', 'unitgradingtypes', '', $unitgradingtypes);
        $mform->setDefault('unitgradingtypes', 1);

        $mform->addGroup($penaltygrp, 'penaltygrp',
                get_string('unitpenalty', 'qtype_numerical'), ' ', false);
        $mform->addHelpButton('penaltygrp', 'unitpenalty', 'qtype_numerical');

        $unitinputoptions = array(
            qtype_numerical::UNITINPUT => get_string('editableunittext', 'qtype_numerical'),
            qtype_numerical::UNITRADIO => get_string('unitchoice', 'qtype_numerical'),
            qtype_numerical::UNITSELECT => get_string('unitselect', 'qtype_numerical'),
        );
        $mform->addElement('select', 'multichoicedisplay',
                get_string('studentunitanswer', 'qtype_numerical'), $unitinputoptions);

        $unitsleftoptions = array(
            0 => get_string('rightexample', 'qtype_numerical'),
            1 => get_string('leftexample', 'qtype_numerical')
        );
        $mform->addElement('select', 'unitsleft',
                get_string('unitposition', 'qtype_numerical'), $unitsleftoptions);
        $mform->setDefault('unitsleft', 0);

        $mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITNONE);
        $mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL);

        $mform->disabledIf('unitsleft', 'unitrole', 'eq', qtype_numerical::UNITNONE);

        $mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITNONE);
        $mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL);
    }
831404
public function edit_field_add($mform) {
        // Create the form field.
        $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
        $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display!
    }
43350
public function setupForm(&$mform) {
        $choices = array('' => get_string('anyvalue', 'filters')) + $this->_options;
        $mform->addElement('select', $this->_name, $this->_label, $choices);
        if ($this->_advanced) {
            $mform->setAdvanced($this->_name);
        }
    }
799326
protected function add_event_repeat_elements($mform) {
        $mform->addElement('checkbox', 'repeat', get_string('repeatevent', 'calendar'), null);
        $mform->addElement('text', 'repeats', get_string('repeatweeksl', 'calendar'), 'maxlength="10" size="10"');
        $mform->setType('repeats', PARAM_INT);
        $mform->setDefault('repeats', 1);
        $mform->disabledIf('repeats', 'repeat', 'notchecked');
        $mform->setAdvanced('repeat');
        $mform->setAdvanced('repeats');
    }
707102
public function edit_field_add($mform) {
        $size = $this->field->param1;
        $maxlength = $this->field->param2;
        $fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');

        // Create the form field.
        $mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
        $mform->setType($this->inputname, PARAM_TEXT);
    }
330273
public function config_form_display(&$mform, $data = null) {
        $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
        $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
        $mform->disabledIf('criteria_grade_value', 'criteria_grade');
        $mform->setType('criteria_grade_value', PARAM_RAW); // Uses unformat_float.
        // Grades are stored in Moodle with 5 decimal points, make sure we do not accidentally round them
        // when setting the form value.
        $mform->setDefault('criteria_grade_value', format_float($data, 5));

        if ($this->id) {
            $mform->setDefault('criteria_grade', 1);
            $mform->setDefault('criteria_grade_value', format_float($this->gradepass, 5));
        }
    }
1294776
public function get_options(&$mform) {
        global $DB;
        $none = true;

        $mform->addElement('header', 'first_header', $this->get_title());
        $mform->addHelpButton('first_header', 'criteria_' . $this->criteriatype, 'badges');

        if ($courses = $DB->get_records('course', array('enablecompletion' => COMPLETION_ENABLED))) {
            $mform->addElement('submit', 'addcourse', get_string('addcourse', 'badges'), array('class' => 'addcourse'));
        }

        // In courseset, print out only the ones that were already selected.
        foreach ($this->params as $p) {
            if ($course = $DB->get_record('course', array('id' => $p['course']))) {
                $coursecontext = context_course::instance($course->id);
                $param = array(
                        'id' => $course->id,
                        'checked' => true,
                        'name' => format_string($course->fullname, true, array('context' => $coursecontext)),
                        'error' => false
                );

                if (isset($p['bydate'])) {
                    $param['bydate'] = $p['bydate'];
                }
                if (isset($p['grade'])) {
                    $param['grade'] = $p['grade'];
                }
                $this->config_options($mform, $param);
                $none = false;
            } else {
                $this->config_options($mform, array('id' => $p['course'], 'checked' => true,
                        'name' => get_string('error:nosuchcourse', 'badges'), 'error' => true));
            }
        }

        // Add aggregation.
        if (!$none) {
            $mform->addElement('header', 'aggregation', get_string('method', 'badges'));
            $agg = array();
            $agg[] =& $mform->createElement('radio', 'agg', '', get_string('allmethodcourseset', 'badges'), 1);
            $agg[] =& $mform->createElement('radio', 'agg', '', get_string('anymethodcourseset', 'badges'), 2);
            $mform->addGroup($agg, 'methodgr', '', array('<br/>'), false);
            if ($this->id !== 0) {
                $mform->setDefault('agg', $this->method);
            } else {
                $mform->setDefault('agg', BADGE_CRITERIA_AGGREGATION_ANY);
            }
        }

        return array($none, get_string('noparamstoadd', 'badges'));
    }
1209166
public function edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext) {
        global $DB;

        $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
        $mform->setType('name', PARAM_TEXT);

        $options = $this->get_status_options();
        $mform->addElement('select', 'status', get_string('status', 'enrol_cohort'), $options);

        $options = ['contextid' => $coursecontext->id, 'multiple' => false];
        $mform->addElement('cohort', 'customint1', get_string('cohort', 'cohort'), $options);

        if ($instance->id) {
            $mform->setConstant('customint1', $instance->customint1);
            $mform->hardFreeze('customint1', $instance->customint1);
        } else {
            $mform->addRule('customint1', get_string('required'), 'required', null, 'client');
        }

        $roles = $this->get_role_options($instance, $coursecontext);
        $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles);
        $mform->setDefault('roleid', $this->get_config('roleid'));
        $groups = $this->get_group_options($coursecontext);
        $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_cohort'), $groups);
    }