Form element definition
197544
public function definition() {
        $form = $this->_form;

        $form->addElement('hidden', 'areaid');
        $form->setType('areaid', PARAM_INT);

        $form->addElement('hidden', 'returnurl');
        $form->setType('returnurl', PARAM_LOCALURL);

        // Name.
        $form->addElement('text', 'name', get_string('name', 'gradingform_guide'),
            array('size' => 52, 'maxlength' => 255));
        $form->addRule('name', get_string('required'), 'required', null, 'client');
        $form->setType('name', PARAM_TEXT);
        $form->addRule('name', null, 'maxlength', 255, 'client');

        // Description.
        $options = gradingform_guide_controller::description_form_field_options($this->_customdata['context']);
        $form->addElement('editor', 'description_editor', get_string('description'), null, $options);
        $form->setType('description_editor', PARAM_RAW);

        // Guide completion status.
        $choices = array();
        $choices[gradingform_controller::DEFINITION_STATUS_DRAFT]    = html_writer::tag('span',
            get_string('statusdraft', 'core_grading'), array('class' => 'status draft'));
        $choices[gradingform_controller::DEFINITION_STATUS_READY]    = html_writer::tag('span',
            get_string('statusready', 'core_grading'), array('class' => 'status ready'));
        $form->addElement('select', 'status', get_string('guidestatus', 'gradingform_guide'), $choices)->freeze();

        // Guide editor.
        $element = $form->addElement('guideeditor', 'guide', get_string('pluginname', 'gradingform_guide'));
        $form->setType('guide', PARAM_RAW);

        $buttonarray = array();
        $buttonarray[] = &$form->createElement('submit', 'saveguide', get_string('saveguide', 'gradingform_guide'));
        if ($this->_customdata['allowdraft']) {
            $buttonarray[] = &$form->createElement('submit', 'saveguidedraft', get_string('saveguidedraft', 'gradingform_guide'));
        }
        $editbutton = &$form->createElement('submit', 'editguide', ' ');
        $editbutton->freeze();
        $buttonarray[] = &$editbutton;
        $buttonarray[] = &$form->createElement('cancel');
        $form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
        $form->closeHeaderBefore('buttonar');
    }
284769
public function definition() {
        global $PAGE;

        $mform = $this->_form;
        $roles = get_roles_for_contextlevels(CONTEXT_USER);

        if (empty($roles)) {
            $output = $PAGE->get_renderer('tool_cohortroles');
            $warning = $output->notify_problem(get_string('noassignableroles', 'tool_cohortroles'));
            $mform->addElement('html', $warning);
            return;
        }

        $options = array(
            'ajax' => 'tool_lp/form-user-selector',
            'multiple' => true
        );
        $mform->addElement('autocomplete', 'userids', get_string('selectusers', 'tool_cohortroles'), array(), $options);
        $mform->addRule('userids', null, 'required');

        $names = role_get_names();
        $options = array();
        foreach ($roles as $idx => $roleid) {
            $options[$roleid] = $names[$roleid]->localname;
        }

        $mform->addElement('select', 'roleid', get_string('selectrole', 'tool_cohortroles'), $options);
        $mform->addRule('roleid', null, 'required');

        $context = context_system::instance();
        $options = array(
            'ajax' => 'tool_lp/form-cohort-selector',
            'multiple' => true,
            'data-contextid' => $context->id,
            'data-includes' => 'all'
        );
        $mform->addElement('autocomplete', 'cohortids', get_string('selectcohorts', 'tool_cohortroles'), array(), $options);
        $mform->addRule('cohortids', null, 'required');
        $mform->addElement('submit', 'submit', get_string('assign', 'tool_cohortroles'));
    }
697319
public function definition() {

        $mform = $this->_form;
        $mform->disable_form_change_checker();
        $componentarray = $this->_customdata['components'];
        $edulevelarray = $this->_customdata['edulevel'];
        $crudarray = $this->_customdata['crud'];

        $mform->addElement('header', 'displayinfo', get_string('filter', 'report_eventlist'));

        $mform->addElement('text', 'eventname', get_string('name', 'report_eventlist'));
        $mform->setType('eventname', PARAM_RAW);

        $mform->addElement('select', 'eventcomponent', get_string('component', 'report_eventlist'), $componentarray);
        $mform->addElement('select', 'eventedulevel', get_string('edulevel', 'report_eventlist'), $edulevelarray);
        $mform->addElement('select', 'eventcrud', get_string('crud', 'report_eventlist'), $crudarray);

        $buttonarray = array();
        $buttonarray[] = $mform->createElement('button', 'filterbutton', get_string('filter', 'report_eventlist'));
        $buttonarray[] = $mform->createElement('button', 'clearbutton', get_string('clear', 'report_eventlist'));
        $mform->addGroup($buttonarray, 'filterbuttons', '', array(' '), false);
    }
723294
function(element) {
            var $element = $(element);
            if ($element.is(':selected')) {
                $element.prop('selected', true);
            }

            // Support the label attribute on options.
            var label = this.options.optionLabel(element);
            var value = $element.val();
            var inputType = this.options.multiple ? "checkbox" : "radio";

            var $li = $(this.options.templates.li);
            var $label = $('label', $li);
            $label.addClass(inputType);

            if (this.options.enableHTML) {
                $label.html(" " + label);
            }
            else {
                $label.text(" " + label);
            }

            var $checkbox = $('<input/>').attr('type', inputType);

            if (this.options.checkboxName) {
                $checkbox.attr('name', this.options.checkboxName);
            }
            $label.prepend($checkbox);

            var selected = $element.prop('selected') || false;
            $checkbox.val(value);

            if (value === this.options.selectAllValue) {
                $li.addClass("multiselect-item multiselect-all");
                $checkbox.parent().parent()
                    .addClass('multiselect-all');
            }

            $label.attr('title', $element.attr('title'));

            this.$ul.append($li);

            if ($element.is(':disabled')) {
                $checkbox.attr('disabled', 'disabled')
                    .prop('disabled', true)
                    .closest('a')
                    .attr("tabindex", "-1")
                    .closest('li')
                    .addClass('disabled');
            }

            $checkbox.prop('checked', selected);

            if (selected && this.options.selectedClass) {
                $checkbox.closest('li')
                    .addClass(this.options.selectedClass);
            }
        }
158975
function() {
        var form = this.element.find('form:first');

        if (!form) {
            return;
        }

        this.fireEvent('submit', [form]);

        var options = {
            url: form.attr('action'),
            type: (form.attr('method') || 'post').toUpperCase()
        };

        if (window.FormData) {
            options.processData = false;
            options.contentType = false;
            options.data = new FormData(form[0]);
        } else {
            options.data = form.serialize();
        }

        this.requestData(options);
    }
980617
function definition() {
        global $USER, $DB, $OUTPUT;

        $mform =& $this->_form;

        if (\core_search\manager::is_search_area_categories_enabled() && !empty($this->_customdata['cat'])) {
            $mform->addElement('hidden', 'cat');
            $mform->setType('cat', PARAM_NOTAGS);
            $mform->setDefault('cat', $this->_customdata['cat']);
        }

        $mform->disable_form_change_checker();
        $mform->addElement('header', 'search', get_string('search', 'search'));

        // Help info depends on the selected search engine.
        $mform->addElement('text', 'q', get_string('enteryoursearchquery', 'search'));
        $mform->addHelpButton('q', 'searchinfo', $this->_customdata['searchengine']);
        $mform->setType('q', PARAM_TEXT);
        $mform->addRule('q', get_string('required'), 'required', null, 'client');

        // Show the 'search within' option if the user came from a particular context.
        if (!empty($this->_customdata['searchwithin'])) {
            $mform->addElement('select', 'searchwithin', get_string('searchwithin', 'search'),
                    $this->_customdata['searchwithin']);
            $mform->setDefault('searchwithin', '');
        }

        // If the search engine provides multiple ways to order results, show options.
        if (!empty($this->_customdata['orderoptions']) &&
                count($this->_customdata['orderoptions']) > 1) {

            $mform->addElement('select', 'order', get_string('order', 'search'),
                    $this->_customdata['orderoptions']);
            $mform->setDefault('order', 'relevance');
        }

        $mform->addElement('header', 'filtersection', get_string('filterheader', 'search'));
        $mform->setExpanded('filtersection', false);

        $mform->addElement('text', 'title', get_string('title', 'search'));
        $mform->setType('title', PARAM_TEXT);

        $search = \core_search\manager::instance(true);
        $enabledsearchareas = \core_search\manager::get_search_areas_list(true);
        $areanames = array();

        if (\core_search\manager::is_search_area_categories_enabled() && !empty($this->_customdata['cat'])) {
            $searchareacategory = \core_search\manager::get_search_area_category_by_name($this->_customdata['cat']);
            $searchareas = $searchareacategory->get_areas();
            foreach ($searchareas as $areaid => $searcharea) {
                if (key_exists($areaid, $enabledsearchareas)) {
                    $areanames[$areaid] = $searcharea->get_visible_name();
                }
            }
        } else {
            foreach ($enabledsearchareas as $areaid => $searcharea) {
                $areanames[$areaid] = $searcharea->get_visible_name();
            }
        }

        // Sort the array by the text.
        \core_collator::asort($areanames);

        $options = array(
            'multiple' => true,
            'noselectionstring' => get_string('allareas', 'search'),
        );
        $mform->addElement('autocomplete', 'areaids', get_string('searcharea', 'search'), $areanames, $options);

        if (is_siteadmin()) {
            $limittoenrolled = false;
        } else {
            $limittoenrolled = !manager::include_all_courses();
        }

        $options = array(
            'multiple' => true,
            'limittoenrolled' => $limittoenrolled,
            'noselectionstring' => get_string('allcourses', 'search'),
        );
        $mform->addElement('course', 'courseids', get_string('courses', 'core'), $options);
        $mform->setType('courseids', PARAM_INT);

        if (manager::include_all_courses() || !empty(get_config('core', 'searchallavailablecourses'))) {
            $mform->addElement('checkbox', 'mycoursesonly', get_string('mycoursesonly', 'search'));
            $mform->setType('mycoursesonly', PARAM_INT);
        }

        // If the search engine can search by user, and the user is logged in (so we have
        // permission to call the user-listing web service) then show the user selector.
        if ($search->get_engine()->supports_users() && isloggedin()) {
            $options = [
                'ajax' => 'core_search/form-search-user-selector',
                'multiple' => true,
                'noselectionstring' => get_string('allusers', 'search'),
                'valuehtmlcallback' => function($value) {
                    global $DB, $OUTPUT;
                    $user = $DB->get_record('user', ['id' => (int)$value], '*', IGNORE_MISSING);
                    if (!$user || !user_can_view_profile($user)) {
                        return false;
                    }
                    $details = user_get_user_details($user);
                    return $OUTPUT->render_from_template(
                            'core_search/form-user-selector-suggestion', $details);
                }
            ];
            if (!empty($this->_customdata['withincourseid'])) {
                $options['withincourseid'] = $this->_customdata['withincourseid'];
            }

            $mform->addElement('autocomplete', 'userids', get_string('users'), [], $options);
        }

        if (!empty($this->_customdata['searchwithin'])) {
            // Course options should be hidden if we choose to search within a specific location.
            $mform->hideIf('courseids', 'searchwithin', 'ne', '');

            // Get groups on course (we don't show group selector if there aren't any).
            $courseid = $this->_customdata['withincourseid'];
            $allgroups = groups_get_all_groups($courseid);
            if ($allgroups && $search->get_engine()->supports_group_filtering()) {
                $groupnames = [];
                foreach ($allgroups as $group) {
                    $groupnames[$group->id] = $group->name;
                }

                // Create group autocomplete option.
                $options = array(
                        'multiple' => true,
                        'noselectionstring' => get_string('allgroups'),
                );
                $mform->addElement('autocomplete', 'groupids', get_string('groups'), $groupnames, $options);

                // Is the second 'search within' option a cm?
                if (!empty($this->_customdata['withincmid'])) {
                    // Find out if the cm supports groups.
                    $modinfo = get_fast_modinfo($courseid);
                    $cm = $modinfo->get_cm($this->_customdata['withincmid']);
                    if ($cm->effectivegroupmode != NOGROUPS) {
                        // If it does, group ids are available when you have course or module selected.
                        $mform->hideIf('groupids', 'searchwithin', 'eq', '');
                    } else {
                        // Group ids are only available if you have course selected.
                        $mform->hideIf('groupids', 'searchwithin', 'ne', 'course');
                    }
                } else {
                    $mform->hideIf('groupids', 'searchwithin', 'eq', '');
                }
            }
        }

        $mform->addElement('date_time_selector', 'timestart', get_string('fromtime', 'search'), array('optional' => true));
        $mform->setDefault('timestart', 0);

        $mform->addElement('date_time_selector', 'timeend', get_string('totime', 'search'), array('optional' => true));
        $mform->setDefault('timeend', 0);

        // Source context i.e. the page they came from when they clicked search.
        $mform->addElement('hidden', 'context');
        $mform->setType('context', PARAM_INT);

        $this->add_action_buttons(false, get_string('search', 'search'));
    }
952980
function(){
		var matches, matchesOverride;
		var exp = $.expr[":"];
		var rElementsGroup = /^(?:form|fieldset)$/i;
		var hasInvalid = function(elem){
			var ret = false;
			$(elem).jProp('elements').each(function(){
				if(!rElementsGroup.test(this.nodeName || '')){
					ret = exp.invalid(this);
					if(ret){
						return false;
					}
				}

			});
			return ret;
		};
		$.extend(exp, {
			"valid-element": function(elem){
				return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) : !!($.prop(elem, 'willValidate') && isValid(elem));
			},
			"invalid-element": function(elem){
				return rElementsGroup.test(elem.nodeName || '') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
			},
			"required-element": function(elem){
				return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
			},
			"user-error": function(elem){
				return ($.prop(elem, 'willValidate') && $(elem).getShadowElement().hasClass((options.iVal.errorClass || 'user-error')));
			},
			"optional-element": function(elem){
				return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
			}
		});
		
		['valid', 'invalid', 'required', 'optional'].forEach(function(name){
			exp[name] = $.expr[":"][name+"-element"];
		});
		
		// sizzle/jQuery has a bug with :disabled/:enabled selectors
		if(support.fieldsetdisabled && !$('<fieldset disabled=""><input /><input /></fieldset>').find(':disabled').filter(':disabled').is(':disabled')){
			matches = $.find.matches;
			matchesOverride = {':disabled': 1, ':enabled': 1};
			$.find.matches = function(expr, elements){
				if(matchesOverride[expr]){
					return matches.call(this, '*'+expr, elements);
				}
				return matches.apply(this, arguments);
			};
			$.extend(exp, {
				"enabled": function( elem ) {
					return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
				},
		
				"disabled": function( elem ) {
					return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
				}
			});
		}
		
		
		//bug was partially fixed in 1.10.0 for IE9, but not IE8 (move to es5 as soon as 1.10.2 is used)
		if(typeof document.activeElement == 'unknown'){
			var pseudoFocus = exp.focus;
			exp.focus = function(){
				try {
					return pseudoFocus.apply(this, arguments);
				} catch(e){
					webshims.error(e);
				}
				return false;
			};
		}
	}
1160437
function ( obj ) {
		return obj.nodeName === "FORM" ? false : string.isEmpty( obj.value || element.text( obj ) );
	}
1191525
public function definition() {
        global $CFG, $OUTPUT;
        $mform = $this->_form;

        $mform->addElement('html', $OUTPUT->doc_link('calendar/export', get_string('exporthelp', 'calendar'), true));

        $export = array();
        $export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsall', 'calendar'), 'all');
        $export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtocategories', 'calendar'), 'categories');
        $export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtocourses', 'calendar'), 'courses');
        $export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtogroups', 'calendar'), 'groups');
        $export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventspersonal', 'calendar'), 'user');

        $mform->addGroup($export, 'events', get_string('eventstoexport', 'calendar'), '<br/>');
        $mform->addGroupRule('events', get_string('required'), 'required');
        $mform->setDefault('events', 'all');

        $range = array();
        if ($this->_customdata['allowthisweek']) {
            $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('weekthis', 'calendar'), 'weeknow');
        }
        if ($this->_customdata['allownextweek']) {
            $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('weeknext', 'calendar'), 'weeknext');
        }
        $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('monththis', 'calendar'), 'monthnow');
        if ($this->_customdata['allownextmonth']) {
            $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('monthnext', 'calendar'), 'monthnext');
        }
        $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('recentupcoming', 'calendar'), 'recentupcoming');

        if ($CFG->calendar_customexport) {
            $a = new stdClass();
            $now = time();
            $time = $now - $CFG->calendar_exportlookback * DAYSECS;
            $a->timestart = userdate($time, get_string('strftimedatefullshort', 'langconfig'));
            $time = $now + $CFG->calendar_exportlookahead * DAYSECS;
            $a->timeend = userdate($time, get_string('strftimedatefullshort', 'langconfig'));

            $range[] = $mform->createElement('radio', 'timeperiod', '', get_string('customexport', 'calendar', $a), 'custom');
        }

        $mform->addGroup($range, 'period', get_string('timeperiod', 'calendar'), '<br/>');
        $mform->addGroupRule('period', get_string('required'), 'required');
        $mform->setDefault('period', 'recentupcoming');

        $buttons = array();
        $buttons[] = $mform->createElement('submit', 'generateurl', get_string('generateurlbutton', 'calendar'));
        $buttons[] = $mform->createElement('submit', 'export', get_string('exportbutton', 'calendar'));
        $mform->addGroup($buttons);
    }
693449
function definition() {
        global $USER;

        $mform    = $this->_form;
        $mform->setDisableShortforms(true);

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

        $purpose = user_edit_map_field_purpose($USER->id, 'username');
        $mform->addElement('text', 'username', get_string('username'), 'size="20"' . $purpose);
        $mform->setType('username', PARAM_RAW);

        $submitlabel = get_string('search');
        $mform->addElement('submit', 'submitbuttonusername', $submitlabel);

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

        $purpose = user_edit_map_field_purpose($USER->id, 'email');
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"' . $purpose);
        $mform->setType('email', PARAM_RAW_TRIMMED);

        $submitlabel = get_string('search');
        $mform->addElement('submit', 'submitbuttonemail', $submitlabel);
    }
662617
public function definition() {
        global $CFG, $DB;
        $mform = $this->_form;

        $config = get_config('imscp');

        // Title and description.
        $mform->addElement('header', 'general', get_string('general', 'form'));
        $mform->addElement('text', 'name', get_string('name'), array('size' => '48'));
        if (!empty($CFG->formatstringstriptags)) {
            $mform->setType('name', PARAM_TEXT);
        } else {
            $mform->setType('name', PARAM_CLEANHTML);
        }
        $mform->addRule('name', null, 'required', null, 'client');
        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
        $this->standard_intro_elements();

        // IMS-CP file upload.
        $mform->addElement('header', 'content', get_string('contentheader', 'imscp'));
        $mform->setExpanded('content', true);
        $mform->addElement('filepicker', 'package', get_string('packagefile', 'imscp'));

        $options = array('-1' => get_string('all'), '0' => get_string('no'),
                         '1' => '1', '2' => '2', '5' => '5', '10' => '10', '20' => '20');
        $mform->addElement('select', 'keepold', get_string('keepold', 'imscp'), $options);
        $mform->setDefault('keepold', $config->keepold);
        $mform->setAdvanced('keepold', $config->keepold_adv);

        $this->standard_coursemodule_elements();

        $this->add_action_buttons();
    }
528308
function _createElements() {
        $attributes = $this->getAttributes();
        if (is_null($attributes)) {
            $attributes = array();
        }
        if (!isset($attributes['size'])) {
            $attributes['size'] = 3;
        }
        $this->_elements = array();
        // E_STRICT creating elements without forms is nasty because it internally uses $this
        $number = $this->createFormElement('text', 'number', get_string('time', 'form'), $attributes, true);
        $number->set_force_ltr(true);
        $this->_elements[] = $number;
        unset($attributes['size']);
        $this->_elements[] = $this->createFormElement('select', 'timeunit', get_string('timeunit', 'form'), $this->get_units(), $attributes, true);
        // If optional we add a checkbox which the user can use to turn if on
        if($this->_options['optional']) {
            $this->_elements[] = $this->createFormElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true);
        }
        foreach ($this->_elements as $element){
            if (method_exists($element, 'setHiddenLabel')){
                $element->setHiddenLabel(true);
            }
        }
    }
1027213
private function renderForm(Form $form) : string
    {
        $html = '';

        foreach ($form->getComponents() as $component) {
            $html .= $this->renderErrors($component);

            if ($component instanceof Element) {
                $html .= $this->renderElement($component);
            } elseif ($component instanceof Group) {
                foreach ($component->getElements() as $element) {
                    $html .= $this->renderElement($element);
                }
            }
        }

        return $html;
    }
102251
def element(label = '&nbsp;', value = '', type = 'text_field', &block)
      value += @template.capture(&block) if block_given?
      %{
        <div class='control-group'>
          <label class='control-label'>#{label}</label>
          <div class='controls'>
            #{value}
          </div>
        </div>
      }.html_safe
    end
983776
function ( obj ) {
		return obj.nodeName === "FORM" ? false : string.isInt( obj.value || element.text( obj ) );
	}
792698
public function buildFormElement($itemName = '', $name = '', $value = '', $id = '', $class = '', $itemValue = '', $attributes = [])
    {
        // Create form input
        $id = $id ?: 'fe' . mt_rand();
        $element = new FormElement($this->getHTMLDocument(), $itemName, $name, $value, $id, $class, $itemValue, $attributes);

        // Return form element
        return $element;
    }
608153
function () {
/*Line 99 - 'AtomForm.js' */                var element = this.get_element();
/*Line 100 - 'AtomForm.js' */                var ae = new ChildEnumerator(element);
/*Line 101 - 'AtomForm.js' */                var formValid = true;
/*Line 102 - 'AtomForm.js' */                while (ae.next()) {
/*Line 103 - 'AtomForm.js' */                    var field = ae.current();
/*Line 104 - 'AtomForm.js' */                    if (!this.validate(field))
/*Line 105 - 'AtomForm.js' */                        formValid = false;
/*Line 106 - 'AtomForm.js' */                }
/*Line 107 - 'AtomForm.js' */                return formValid;
/*Line 108 - 'AtomForm.js' */            }