Adds "Agree to site policy" checkbox to the signup form.

Sitepolicy handlers can override the simple checkbox with their own controls.

@param \MoodleQuickForm $mform
776862
public static function signup_form($mform) {
        if ($url = static::get_embed_url()) {
            $mform->addElement('header', 'policyagreement', get_string('policyagreement'), '');
            $mform->setExpanded('policyagreement');
            $mform->addElement('static', 'policylink', '', '<a href="' . $url .
                '" onclick="this.target=\'_blank\'">' . get_string('policyagreementclick') . '</a>');
            $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept'));
            $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'client');
        }
    }
110095
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
        global $CFG;

        $hosts = $this->get_valid_hosts_options();
        $mform->addElement('select', 'customint1', get_string('remotesubscriber', 'enrol_mnet'), $hosts);
        $mform->addHelpButton('customint1', 'remotesubscriber', 'enrol_mnet');
        $mform->addRule('customint1', get_string('required'), 'required', null, 'client');

        $roles = $this->get_valid_roles_options($context);
        $mform->addElement('select', 'roleid', get_string('roleforremoteusers', 'enrol_mnet'), $roles);
        $mform->addHelpButton('roleid', 'roleforremoteusers', 'enrol_mnet');
        $mform->addRule('roleid', get_string('required'), 'required', null, 'client');
        $mform->setDefault('roleid', $this->get_config('roleid'));

        $mform->addElement('text', 'name', get_string('instancename', 'enrol_mnet'));
        $mform->addHelpButton('name', 'instancename', 'enrol_mnet');
        $mform->setType('name', PARAM_TEXT);
    }
353879
public function config_form_display(&$mform, $data = null) {
        $mform->addElement('checkbox', 'criteria_unenrol', get_string('enable'));

        if ($this->id) {
            $mform->setDefault('criteria_unenrol', 1);
        }
    }
321121
public function config_form_definition(\MoodleQuickForm $mform) {
        $mform->addElement('header', 'header_specificsettings', get_string('specificsettings', 'customfield_textarea'));
        $mform->setExpanded('header_specificsettings', true);

        $desceditoroptions = $this->value_editor_options();

        $mform->addElement('editor', 'configdata[defaultvalue_editor]', get_string('defaultvalue', 'core_customfield'),
            null, $desceditoroptions);
    }
885195
public function edit_field_add($mform) {
        // Create the form field.
        $checkbox = $mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
        if ($this->data == '1') {
            $checkbox->setChecked(true);
        }
        $mform->setType($this->inputname, PARAM_BOOL);
        if ($this->is_required() and !has_capability('moodle/user:update', context_system::instance())) {
            $mform->addRule($this->inputname, get_string('required'), 'nonzero', null, 'client');
        }
    }
667018
public function instance_form_definition(\MoodleQuickForm $mform) {
        $field = $this->get_field();
        $config = $field->get('configdata');
        $elementname = $this->get_form_element_name();
        $mform->addElement('advcheckbox', $elementname, $this->get_field()->get_formatted_name());
        $mform->setDefault($elementname, $config['checkbydefault']);
        $mform->setType($elementname, PARAM_BOOL);
        if ($field->get_configdata_property('required')) {
            $mform->addRule($elementname, null, 'required', null, 'client');
        }
    }
237735
public static function type_config_form($mform, $classname = 'repository') {
        $api_key = get_config('flickr_public', 'api_key');
        if (empty($api_key)) {
            $api_key = '';
        }
        $strrequired = get_string('required');

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

        $mform->addElement('static', null, '',  get_string('information','repository_flickr_public'));
    }
72629
protected function choice_group($mform) {
        $options = array();
        for ($i = 1; $i <= $this->get_maximum_choice_group_number(); $i += 1) {
            $options[$i] = question_utils::int_to_letter($i);
        }
        $grouparray = array();
        $grouparray[] = $mform->createElement('text', 'answer',
                get_string('answer', 'qtype_gapselect'), array('size' => 30, 'class' => 'tweakcss'));
        $grouparray[] = $mform->createElement('select', 'choicegroup',
                get_string('group', 'qtype_gapselect'), $options);
        return $grouparray;
    }
39602
public function instance_form_definition(\MoodleQuickForm $mform) {
        $field = $this->get_field();
        $config = $field->get('configdata');
        $options = field_controller::get_options_array($field);
        $formattedoptions = array();
        $context = $this->get_field()->get_handler()->get_configuration_context();
        foreach ($options as $key => $option) {
            // Multilang formatting with filters.
            $formattedoptions[$key] = format_string($option, true, ['context' => $context]);
        }

        $elementname = $this->get_form_element_name();
        $mform->addElement('select', $elementname, $this->get_field()->get_formatted_name(), $formattedoptions);

        if (($defaultkey = array_search($config['defaultvalue'], $options)) !== false) {
            $mform->setDefault($elementname, $defaultkey);
        }
        if ($field->get_configdata_property('required')) {
            $mform->addRule($elementname, null, 'required', null, 'client');
        }
    }
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);
    }
389868
protected function add_collection_selector($mform) {
        $tagcolls = core_tag_collection::get_collections_menu(false, false, get_string('anycollection', 'block_tags'));
        if (count($tagcolls) <= 1) {
            return;
        }

        $tagcollssearchable = core_tag_collection::get_collections_menu(false, true);
        $hasunsearchable = false;
        foreach ($tagcolls as $id => $name) {
            if ($id && !array_key_exists($id, $tagcollssearchable)) {
                $hasunsearchable = true;
                $tagcolls[$id] = $name . '*';
            }
        }

        $mform->addElement('select', 'config_tagcoll', get_string('tagcollection', 'block_tags'), $tagcolls);
        if ($hasunsearchable) {
            $mform->addHelpButton('config_tagcoll', 'tagcollection', 'block_tags');
        }
        $mform->setDefault('config_tagcoll', 0);
    }
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);
        }
    }
693338
public function edit_field_add($mform) {
        // Get the current calendar in use - see MDL-18375.
        $calendartype = \core_calendar\type_factory::get_calendar_instance();

        // Check if the field is required.
        if ($this->field->required) {
            $optional = false;
        } else {
            $optional = true;
        }

        // Convert the year stored in the DB as gregorian to that used by the calendar type.
        $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1);
        $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1);

        $attributes = array(
            'startyear' => $startdate['year'],
            'stopyear'  => $stopdate['year'],
            'optional'  => $optional
        );

        // Check if they wanted to include time as well.
        if (!empty($this->field->param3)) {
            $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes);
        } else {
            $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes);
        }

        $mform->setType($this->inputname, PARAM_INT);
        $mform->setDefault($this->inputname, time());
    }
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');
    }
391427
public function edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext) {
        global $DB;

        $groups = $this->get_group_options($coursecontext);
        $existing = $DB->get_records('enrol', array('enrol' => 'meta', 'courseid' => $coursecontext->instanceid), '', 'customint1, id');

        $excludelist = array($coursecontext->instanceid);
        foreach ($existing as $existinginstance) {
            $excludelist[] = $existinginstance->customint1;
        }

        $options = array(
            'requiredcapabilities' => array('enrol/meta:selectaslinked'),
            'multiple' => empty($instance->id),  // We only accept multiple values on creation.
            'exclude' => $excludelist
        );
        $mform->addElement('course', 'customint1', get_string('linkedcourse', 'enrol_meta'), $options);
        $mform->addRule('customint1', get_string('required'), 'required', null, 'client');
        if (!empty($instance->id)) {
            $mform->freeze('customint1');
        }

        $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_meta'), $groups);
    }
218114
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {

        $options = $this->get_status_options();
        $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
        $mform->addHelpButton('status', 'status', 'enrol_manual');
        $mform->setDefault('status', $this->get_config('status'));

        $roles = $this->get_roleid_options($instance, $context);
        $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
        $mform->setDefault('roleid', $this->get_config('roleid'));

        $options = array('optional' => true, 'defaultunit' => 86400);
        $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
        $mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
        $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');

        $options = $this->get_expirynotify_options();
        $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
        $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');

        $options = array('optional' => false, 'defaultunit' => 86400);
        $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
        $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
        $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);

        if (enrol_accessing_via_instance($instance)) {
            $warntext = get_string('instanceeditselfwarningtext', 'core_enrol');
            $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext);
        }
    }
1012927
public function setupForm(&$mform) {
        $obj =& $mform->addElement('select', $this->_name, $this->_label, $this->get_roles());
        $mform->setDefault($this->_name, 0);
        if ($this->_advanced) {
            $mform->setAdvanced($this->_name);
        }
    }