Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Classes | |
class | form_filemanager |
Data structure representing a file manager. More... | |
class | moodleform |
Wrapper that separates quickforms syntax from moodle code. More... | |
class | MoodleQuickForm |
MoodleQuickForm implementation. More... | |
class | MoodleQuickForm_advcheckbox |
Advanced checkbox type form element. More... | |
class | MoodleQuickForm_button |
Button form element. More... | |
class | MoodleQuickForm_cancel |
HTML class for a submit cancel type element. More... | |
class | MoodleQuickForm_checkbox |
checkbox form element More... | |
class | MoodleQuickForm_date_selector |
Class for a group of elements used to input a date. More... | |
class | MoodleQuickForm_date_time_selector |
Element used to input a date and time. More... | |
class | MoodleQuickForm_duration |
Duration element. More... | |
class | MoodleQuickForm_editor |
Editor element. More... | |
class | MoodleQuickForm_filemanager |
Filemanager form element. More... | |
class | MoodleQuickForm_filepicker |
Filepicker form element. More... | |
class | MoodleQuickForm_filetypes |
File types and type groups selection form element. More... | |
class | MoodleQuickForm_float |
Float type form element. More... | |
class | MoodleQuickForm_grading |
Advance grading form element. More... | |
class | MoodleQuickForm_group |
Form element group. More... | |
class | MoodleQuickForm_header |
Header form element. More... | |
class | MoodleQuickForm_hidden |
Hidden type form element. More... | |
class | MoodleQuickForm_modgrade |
Drop down form element to select the grade. More... | |
class | MoodleQuickForm_modvisible |
Drop down form element to select visibility in an activity mod update form. More... | |
class | MoodleQuickForm_password |
Password type form element. More... | |
class | MoodleQuickForm_passwordunmask |
Password type form element with unmask option. More... | |
class | MoodleQuickForm_questioncategory |
Drop down for question categories. More... | |
class | MoodleQuickForm_radio |
radio type form element More... | |
class | MoodleQuickForm_recaptcha |
recaptcha type form element More... | |
class | MoodleQuickForm_select |
select type form element More... | |
class | MoodleQuickForm_selectgroups |
select type form element More... | |
class | MoodleQuickForm_selectwithlink |
select type form element More... | |
class | MoodleQuickForm_selectyesno |
Yes/No drop down type form element. More... | |
class | MoodleQuickForm_static |
Text type form element. More... | |
class | MoodleQuickForm_submit |
submit type form element More... | |
class | MoodleQuickForm_text |
Text type form element. More... | |
class | MoodleQuickForm_textarea |
Textarea type form element. More... | |
class | MoodleQuickForm_url |
url type form element More... | |
class | MoodleQuickForm_warning |
static warning element More... | |
Functions | |
moodleform::__construct ($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true, $ajaxformdata=null) | |
The constructor function calls the abstract function definition() and it will then process and clean and attempt to validate incoming data. | |
MoodleQuickForm::__construct ($formName, $method, $action, $target='', $attributes=null, $ajaxformdata=null) | |
Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless. | |
moodleform::_get_post_params () | |
Internal method - should not be used anywhere. | |
moodleform::_process_submission ($method) | |
Internal method. | |
moodleform::_validate_files (&$files) | |
Internal method. | |
MoodleQuickForm::accept (&$renderer) | |
Accepts a renderer. | |
moodleform::add_action_buttons ($cancel=true, $submitlabel=null) | |
Use this method to a cancel and submit button to the end of your form. | |
moodleform::add_checkbox_controller ($groupid, $text=null, $attributes=null, $originalValue=0) | |
Adds a link/button that controls the checked state of a group of checkboxes. | |
moodleform::add_sticky_action_buttons (bool $cancel=true, ?string $submitlabel=null) | |
Use this method to make a sticky submit/cancel button at the end of your form. | |
MoodleQuickForm::addAdvancedStatusElement ($headerid, $showmore=false) | |
Use this method to add show more/less status element required for passing over the advanced elements visibility status on the form submission. | |
MoodleQuickForm::addGroupRule ($group, $arg1, $type='', $format=null, $howmany=0, $validation='server', $reset=false) | |
Adds a validation rule for the given group of elements. | |
MoodleQuickForm::addHelpButton ( $elementname, $identifier, $component='moodle', $linktext='', $suppresscheck=false, $a=null) | |
Add a help button to element, only one button per element is allowed. | |
MoodleQuickForm::addRule ($element, $message, $type, $format=null, $validation='server', $reset=false, $force=false) | |
Adds a validation rule for the given field. | |
moodleform::after_definition () | |
After definition hook. | |
MoodleQuickForm::closeHeaderBefore ($elementName) | |
Adds one or more element names that indicate the end of a fieldset. | |
moodleform::definition () | |
Form definition. | |
moodleform::definition_after_data () | |
Dummy stub method - override if you need to setup the form depending on current values. | |
MoodleQuickForm::disable_form_change_checker () | |
Call this method if you don't want the formchangechecker JavaScript to be automatically initialised for this form. | |
moodleform::display () | |
Print html form. | |
MoodleQuickForm::enable_form_change_checker () | |
If you have called disable_form_change_checker() then you can use this method to re-enable it. | |
MoodleQuickForm::exportValues ($elementList=null) | |
export submitted values | |
moodleform::filter_shown_headers (array $shownonly) | |
Use this method to indicate that the fieldsets should be shown as expanded and all other fieldsets should be hidden. | |
MoodleQuickForm::filter_shown_headers (array $shownonly) | |
Use this method to indicate that the fieldsets should be shown and expanded and all other fieldsets should be hidden. | |
moodleform::focus ($name=NULL) | |
To autofocus on first form element or first element with error. | |
if( $CFG->debugdeveloper) moodle_page | form_init_date_js () |
Initalize javascript for date type form element. | |
moodleform::get_array_value_by_keys (array $array, array $keys) | |
Returns an element of multi-dimensional array given the list of keys. | |
moodleform::get_data () | |
Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data. | |
moodleform::get_draft_files ($elname) | |
Get draft files of a form element This is a protected method which will be used only inside moodleforms. | |
moodleform::get_file_content ($elname) | |
Get content of uploaded file. | |
moodleform::get_form_identifier () | |
It should returns unique identifier for the form. | |
static | moodleform::get_js_module () |
Returns a JS module definition for the mforms JS. | |
moodleform::get_new_filename ($elname=null) | |
Returns name of uploaded file. | |
moodleform::get_submitted_data () | |
Return submitted data without validation or NULL if there is no submitted data. | |
MoodleQuickForm::getAdvancedHTML () | |
Returns HTML for advanced elements. | |
MoodleQuickForm::getCleanedValue ($value, $type) | |
Return the cleaned value using the passed type(s). | |
MoodleQuickForm::getCleanType ($elementname, $value, $default=PARAM_RAW) | |
Return the type(s) to use to clean an element. | |
MoodleQuickForm::getReqHTML () | |
Returns HTML for required elements. | |
MoodleQuickForm::getShowAdvanced () | |
This function has been deprecated. | |
MoodleQuickForm::getValidationScript () | |
Returns the client side validation script. | |
moodleform::init_javascript_enhancement ($element, $enhancement, array $options=array(), array $strings=null) | |
Adds an initialisation call for a standard JavaScript enhancement. | |
moodleform::is_cancelled () | |
Return true if a cancel button has been pressed resulting in the form being submitted. | |
MoodleQuickForm::is_dirty () | |
Is the form currently set to dirty? | |
MoodleQuickForm::is_form_change_checker_enabled () | |
MoodleQuickForm::is_shown (string $headername) | |
Use this method to check if the fieldsets could be shown. | |
moodleform::is_submitted () | |
Check that form was submitted. | |
moodleform::is_validated () | |
Check that form data is valid. | |
static | moodleform::mock_ajax_submit ($simulatedsubmitteddata, $simulatedsubmittedfiles=array(), $method='post', $formidentifier=null) |
Used by tests to simulate submitted form data submission via AJAX. | |
static | moodleform::mock_generate_submit_keys ($data=[]) |
Used by tests to generate valid submit keys for moodle forms that are submitted with ajax data. | |
static | moodleform::mock_submit ($simulatedsubmitteddata, $simulatedsubmittedfiles=array(), $method='post', $formidentifier=null) |
Used by tests to simulate submitted form data submission from the user. | |
moodleform::moodleform ($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) | |
Old syntax of class constructor. | |
MoodleQuickForm::MoodleQuickForm ($formName, $method, $action, $target='', $attributes=null) | |
Old syntax of class constructor. | |
moodleform::no_submit_button_pressed () | |
Checks if button pressed is not for submitting the form. | |
moodleform::optional_param ($name, $default, $type) | |
Checks if a parameter was passed in the previous form submission. | |
MoodleQuickForm::optional_param ($name, $default, $type) | |
Checks if a parameter was passed in the previous form submission. | |
pear_handle_error ($error) | |
Callback called when PEAR throws an error. | |
MoodleQuickForm::prepare_fixed_value ($name, $value) | |
This is a bit of a hack, and it duplicates the code in HTML_QuickForm_element\_prepareValue, but I could not think of a way or reliably calling that code. | |
moodleform::render () | |
Renders the html form (same as display, but returns the result). | |
moodleform::repeat_elements ($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=null, $addbuttoninside=false, $deletebuttonname='') | |
Method to add a repeating group of elements to a form. | |
moodleform::repeat_elements_fix_clone ($i, $elementclone, &$namecloned) | |
Helper used by repeat_elements(). | |
moodleform::save_file ($elname, $pathname, $override=false) | |
Save file to standard filesystem. | |
moodleform::save_files ($destination) | |
Save verified uploaded files into directory. | |
moodleform::save_stored_file ($elname, $newcontextid, $newcomponent, $newfilearea, $newitemid, $newfilepath='/', $newfilename=null, $overwrite=false, $newuserid=null) | |
Save file to local filesystem pool. | |
moodleform::save_temp_file ($elname) | |
Returns a temporary file, do not forget to delete after not needed any more. | |
moodleform::set_data ($default_values) | |
Load in existing data as form defaults. | |
moodleform::set_display_vertical () | |
Set display mode for the form when labels take full width of the form and above the elements even on big screens. | |
moodleform::set_initial_dirty_state ($state=false) | |
Set the initial 'dirty' state of the form. | |
MoodleQuickForm::set_initial_dirty_state ($state=false) | |
Set the initial 'dirty' state of the form. | |
MoodleQuickForm::set_sticky_footer (?string $elementname) | |
Use this method to indicate an element to display as a sticky footer. | |
MoodleQuickForm::setAdvanced ($elementName, $advanced=true) | |
Use this method to indicate an element in a form is an advanced field. | |
MoodleQuickForm::setConstant ($elname, $value) | |
Set constant value not overridden by _POST or _GET note: this does not work for complex names with [] :-(. | |
MoodleQuickForm::setDefault ($elementName, $defaultValue) | |
Initializes a default form value. | |
MoodleQuickForm::setDisableShortforms ($disable=true) | |
Use this method to indicate that the form will not be using shortforms. | |
MoodleQuickForm::setExpanded ($headername, $expanded=true, $ignoreuserstate=false) | |
Use this method to indicate that the fieldset should be shown as expanded. | |
MoodleQuickForm::setForceLtr ($elementname, $value=true) | |
Set an element to be forced to flow LTR. | |
MoodleQuickForm::setShowAdvanced ($showadvancedNow=null) | |
This function has been deprecated. | |
MoodleQuickForm::setType ($elementname, $paramtype) | |
Should be used for all elements of a form except for select, radio and checkboxes which clean their own data. | |
MoodleQuickForm::setTypes ($paramtypes) | |
This can be used to set several types at once. | |
MoodleQuickForm::updateSubmission ($submission, $files) | |
Updates submitted values. | |
moodleform::validate_defined_fields ($validateonnosubmit=false) | |
Validate the form. | |
moodleform::validate_draft_files () | |
Internal method. | |
moodleform::validation ($data, $files) | |
Dummy stub method - override if you needed to perform some extra validation. | |
Variables | |
array | MoodleQuickForm::$_advancedElements = array() |
Array whose keys are element names. | |
string | MoodleQuickForm::$_advancedHTML |
advanced class HTML. | |
array | moodleform::$_ajaxformdata |
submitted form data when using mforms with ajax | |
array | MoodleQuickForm::$_ajaxformdata |
$_ajaxformdata submitted form data when using mforms with ajax | |
array | MoodleQuickForm::$_cancelButtons =array() |
Array of buttons that if pressed do not result in the processing of the form. | |
array | MoodleQuickForm::$_collapsibleElements = array() |
Array whose keys are element names and values are the desired collapsible state. | |
mixed | moodleform::$_customdata |
globals workaround | |
object | moodleform::$_definition_finalized = false |
definition_after_data executed flag | |
array | MoodleQuickForm::$_dependencies = array() |
dependent state for the element/'s | |
boolean | MoodleQuickForm::$_disableShortforms = false |
Whether to enable shortforms for this form. | |
MoodleQuickForm | moodleform::$_form |
quickform object definition | |
string | MoodleQuickForm::$_formName = '' |
The form name is derived from the class name of the wrapper minus the trailing form It is a name with words joined by underscores whereas the id attribute is words joined by underscores. | |
string | moodleform::$_formname |
name of the form | |
array | MoodleQuickForm::$_hideifs = array() |
elements that will become hidden based on another element | |
bool | MoodleQuickForm::$_initial_form_dirty_state = false |
The initial state of the dirty state. | |
array | MoodleQuickForm::$_newrepeats = array() |
names of new repeating elements that should not expect to find submitted data | |
array | MoodleQuickForm::$_noSubmitButtons =array() |
Array of buttons that if pressed do not result in the processing of the form. | |
string | MoodleQuickForm::$_pageparams = '' |
String with the html for hidden params passed in as part of a moodle_url object for the action. | |
string | MoodleQuickForm::$_reqHTML |
request class HTML. | |
array | MoodleQuickForm::$_shownonlyelements = [] |
Array whose keys are the only elements to be shown. | |
string null | MoodleQuickForm::$_stickyfooterelement = null |
The form element to render in the sticky footer, if any. | |
array | MoodleQuickForm::$_types = array() |
type (PARAM_INT, PARAM_TEXT etc) of element value | |
bool | MoodleQuickForm::$_use_form_change_checker = true |
whether to automatically initialise the form change detector this form. | |
bool null | moodleform::$_validated = null |
stores the validation result of this form or null if not yet validated | |
if(!defined('MOODLE_INTERNAL')) global | $CFG |
Button form element. | |
global | $CFG |
Group of date input element. | |
global | $CFG |
Group of date and time input element. | |
global | $CFG |
Duration form element. | |
global | $CFG |
Editor input element. | |
global | $CFG |
FileManager form element. | |
global | $CFG |
Filepicker form element. | |
global | $CFG |
global | $CFG |
global | $CFG |
Advance grading form element. | |
global | $CFG |
Drop down form element to select the grade. | |
global | $CFG |
Drop down form element to select visibility in an activity mod update form. | |
if(!defined('MOODLE_INTERNAL')) global | $CFG |
Password type form element with unmask option. | |
global | $CFG |
Drop down for question categories. | |
global | $CFG |
Yes/No drop down type form element. | |
bool | MoodleQuickForm::$clientvalidation = false |
Whether the form contains any client-side validation or not. | |
static int | moodleform::$uniqueid = 0 |
Unique identifier to be used for action buttons. | |
const | MoodleQuickForm::DEP_DISABLE = 0 |
Is this a 'disableIf' dependency ? | |
const | MoodleQuickForm::DEP_HIDE = 1 |
Is this a 'hideIf' dependency? | |
const | EDITOR_UNLIMITED_FILES -1 |
setup.php includes our hacked pear libs first | |
moodleform::__construct | ( | $action = null, | |
$customdata = null, | |||
$method = 'post', | |||
$target = '', | |||
$attributes = null, | |||
$editable = true, | |||
$ajaxformdata = null ) |
The constructor function calls the abstract function definition() and it will then process and clean and attempt to validate incoming data.
It will call your custom validate method to validate data and will also check any rules you have specified in definition using addRule
The name of the form (id attribute of the form) is automatically generated depending on the name you gave the class extending moodleform. You should call your class something like
mixed | $action | the action attribute for the form. If empty defaults to auto detect the current url. If a moodle_url object then outputs params as hidden variables. |
mixed | $customdata | if your form defintion method needs access to data such as $course $cm, etc. to construct the form definition then pass it in this array. You can use globals for somethings. |
string | $method | if you set this to anything other than 'post' then _GET and _POST will be merged and used as incoming data to the form. |
string | $target | target frame for form submission. You will rarely use this. Don't use it if you don't need to as the target attribute is deprecated in xhtml strict. |
mixed | $attributes | you can pass a string of html attributes here or an array. Special attribute 'data-random-ids' will randomise generated elements ids. This is necessary when there are several forms on the same page. Special attribute 'data-double-submit-protection' set to 'off' will turn off double-submit protection JavaScript - this may be necessary if your form sends downloadable files in response to a submit button, and can't call core_form\util\form_download_complete(); |
bool | $editable | |
array | $ajaxformdata | Forms submitted via ajax, must pass their data here, instead of relying on _GET and _POST. |
Reimplemented in assign_override_form, core_completion_defaultedit_form, feedback_edit_create_template_form, feedback_edit_use_template_form, mod_feedback_use_templ_form, and tool_mfa\local\form\login_form.
MoodleQuickForm::__construct | ( | $formName, | |
$method, | |||
$action, | |||
$target = '', | |||
$attributes = null, | |||
$ajaxformdata = null ) |
Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless.
@staticvar int $formcounter counts number of forms
string | $formName | Form's name. |
string | $method | Form's method defaults to 'POST' |
string | moodle_url | $action | Form's action |
string | $target | (optional)Form's target defaults to none |
mixed | $attributes | (optional)Extra attributes for <form> tag |
array | $ajaxformdata | Forms submitted via ajax, must pass their data here, instead of relying on _GET and _POST. |
|
protected |
moodleform::_process_submission | ( | $method | ) |
Internal method.
Alters submitted data to be suitable for quickforms processing. Must be called when the form is fully set up.
string | $method | name of the method which alters submitted data |
moodleform::_validate_files | ( | & | $files | ) |
Internal method.
Validates all old-style deprecated uploaded files. The new way is to upload files via repository api.
array | $files | list of files to be validated |
bool|array | Success or an array of errors |
MoodleQuickForm::accept | ( | & | $renderer | ) |
Accepts a renderer.
HTML_QuickForm_Renderer | $renderer | An HTML_QuickForm_Renderer object |
moodleform::add_action_buttons | ( | $cancel = true, | |
$submitlabel = null ) |
Use this method to a cancel and submit button to the end of your form.
Pass a param of false if you don't want a cancel button in your form. If you have a cancel button make sure you check for it being pressed using is_cancelled() and redirecting if it is true before trying to get data with get_data().
bool | $cancel | whether to show cancel button, default true |
string | $submitlabel | label for submit button, defaults to get_string('savechanges') |
Reimplemented in core_badges\form\backpack, core_contentbank\form\edit_content, and tool_uploadcourse_step2_form.
moodleform::add_checkbox_controller | ( | $groupid, | |
$text = null, | |||
$attributes = null, | |||
$originalValue = 0 ) |
Adds a link/button that controls the checked state of a group of checkboxes.
int | $groupid | The id of the group of advcheckboxes this element controls |
string | $text | The text of the link. Defaults to selectallornone ("select all/none") |
array | $attributes | associative array of HTML attributes |
int | $originalValue | The original general state of the checkboxes before the user first clicks this element |
moodleform::add_sticky_action_buttons | ( | bool | $cancel = true, |
?string | $submitlabel = null ) |
Use this method to make a sticky submit/cancel button at the end of your form.
bool | $cancel | whether to show cancel button, default true |
string | null | $submitlabel | label for submit button, defaults to get_string('savechanges') |
MoodleQuickForm::addAdvancedStatusElement | ( | $headerid, | |
$showmore = false ) |
Use this method to add show more/less status element required for passing over the advanced elements visibility status on the form submission.
string | $headerName | header element name. |
boolean | $showmore | default false sets the advanced elements to be hidden. |
MoodleQuickForm::addGroupRule | ( | $group, | |
$arg1, | |||
$type = '', | |||
$format = null, | |||
$howmany = 0, | |||
$validation = 'server', | |||
$reset = false ) |
Adds a validation rule for the given group of elements.
Only groups with a name can be assigned a validation rule Use addGroupRule when you need to validate elements inside the group. Use addRule if you need to validate the group as a whole. In this case, the same rule will be applied to all elements in the group. Use addRule if you need to validate the group against a function.
string | $group | Form group name |
array | string | $arg1 | Array for multiple elements or error message string for one element |
string | $type | (optional)Rule type use getRegisteredRules() to get types |
string | $format | (optional)Required for extra rule data |
int | $howmany | (optional)How many valid elements should be in the group |
string | $validation | (optional)Where to perform validation: "server", "client" |
bool | $reset | Client-side: whether to reset the element's value to its original state if validation failed. |
MoodleQuickForm::addHelpButton | ( | $elementname, | |
$identifier, | |||
$component = 'moodle', | |||
$linktext = '', | |||
$suppresscheck = false, | |||
$a = null ) |
Add a help button to element, only one button per element is allowed.
This is new, simplified and preferable method of setting a help icon on form elements. It uses the new $OUTPUT->help_icon().
Typically, you will provide the same identifier and the component as you have used for the label of the element. The string identifier with the _help suffix added is then used as the help string.
There has to be two strings defined: 1/ get_string($identifier, $component) - the title of the help page 2/ get_string($identifier.'_help', $component) - the actual help page text
string | $elementname | name of the element to add the item to |
string | $identifier | help string identifier without _help suffix |
string | $component | component name to look the help string in |
string | $linktext | optional text to display next to the icon |
bool | $suppresscheck | set to true if the element may not exist |
string | object | array | int | $a | An object, string or number that can be used within translation strings |
MoodleQuickForm::addRule | ( | $element, | |
$message, | |||
$type, | |||
$format = null, | |||
$validation = 'server', | |||
$reset = false, | |||
$force = false ) |
Adds a validation rule for the given field.
If the element is in fact a group, it will be considered as a whole. To validate grouped elements as separated entities, use addGroupRule instead of addRule.
string | $element | Form element name |
string | null | $message | Message to display for invalid data |
string | $type | Rule type, use getRegisteredRules() to get types |
mixed | $format | (optional)Required for extra rule data |
string | $validation | (optional)Where to perform validation: "server", "client" |
bool | $reset | Client-side validation: reset the form element to its original value if there is an error? |
bool | $force | Force the rule to be applied, even if the target form element does not exist |
|
protected |
After definition hook.
This is useful for intermediate classes to inject logic after the definition was provided without requiring developers to call the parent self::definition()
} as it's not obvious by design. The 'intermediate' class is 'MyClass extends IntermediateClass extends moodleform'.
Classes overriding this method should always call the parent. We may not add anything specifically in this instance of the method, but intermediate classes are likely to do so, and so it is a good practice to always call the parent.
void |
MoodleQuickForm::closeHeaderBefore | ( | $elementName | ) |
Adds one or more element names that indicate the end of a fieldset.
string | $elementName | name of the element |
|
abstractprotected |
Form definition.
Abstract method - always override!
Reimplemented in admin_uploadpicture_form, admin_uploaduser_form1, admin_uploaduser_form2, alignment_form, assign_override_form, assignfeedback_file_batch_upload_files_form, assignfeedback_file_import_zip_form, assignfeedback_file_upload_zip_form, assignfeedback_offline_import_grades_form, assignfeedback_offline_upload_grades_form, atto_managefiles_manage_form, autogroup_form, backup_files_edit_form, badges_preferences_form, base_moodleform, block_edit_form, blog_edit_external_form, blog_edit_form, blog_preferences_form, book_chapter_edit_form, booktool_importhtml_form, cache_definition_mappings_form, cache_definition_sharing_form, cache_lock_form, cache_mode_mappings_form, cachestore_addinstance_form, cohort_edit_form, cohort_upload_form, contenttype_h5p\form\editor, core\form\error_feedback, core\hub\site_registration_form, core_admin\form\purge_caches, core_admin\form\testoutgoingmailconf_form, core_auth\form\verify_age_location_form, core_backup\output\copy_form, core_badges\form\backpack, core_badges\form\badge, core_badges\form\collections, core_badges\form\external_backpack, core_badges\form\message, core_cache\output\usage_samples_form, core_calendar\local\event\forms\create, core_calendar\local\event\forms\managesubscriptions, core_calendar_export_form, core_communication\form\configure_form, core_completion_bulkedit_form, core_completion_defaultedit_form, core_completion_edit_base_form, core_contentbank\form\upload_files, core_course_deletecategory_form, core_course_editcategory_form, core_customfield\field_config_form, core_enrol\form\renameroles, core_grades\form\add_category, core_grades\form\add_item, core_grades\form\add_outcome, core_h5p\form\editcontent_form, core_h5p\form\uploadlibraries_form, core_reportbuilder\form\audience, core_reportbuilder\form\card_view, core_reportbuilder\form\condition, core_reportbuilder\form\filter, core_reportbuilder\form\report, core_reportbuilder\form\schedule, core_role_permission_allow_form, core_role_permission_prohibit_form, core_role_preset_form, core_search\output\form\search, core_user\form\calendar_form, core_user\form\contactsitesupport_form, core_user\form\contentbank_user_preferences_form, core_user\form\defaulthomepage_form, core_user\form\private_files, core_user\form\profile_category_form, core_user\form\profile_field_form, core_webservice\token_filter, core_webservice\token_form, course_completion_form, course_edit_form, course_request_form, course_reset_form, course_restore_form, course_settings_form, coursefiles_edit_form, coursetags_form, data_existing_preset_form, data_export_form, data_import_preset_zip_form, data_save_preset_form, database_export_form, database_transfer_form, edit_calculation_form, edit_category_form, edit_criteria_form, edit_grade_form, edit_item_form, edit_letter_form, edit_outcome_form, edit_outcomeitem_form, edit_relatedbadge_form, edit_scale_form, editsection_form, endorsement_form, enrol_bulk_enrolment_change_form, enrol_bulk_enrolment_confirm_form, enrol_guest_enrol_form, enrol_instance_edit_form, enrol_lti\local\ltiadvantage\form\create_registration_form, enrol_lti\local\ltiadvantage\form\deployment_form, enrol_lti\local\ltiadvantage\form\platform_registration_form, enrol_manual_enrol_users_form, enrol_self_empty_form, enrol_self_enrol_form, enrol_user_enrolment_form, enrol_users_addmember_form, enrol_users_assign_form, enrol_users_filter_form, essay_grading_form, event_form, external_service_authorised_user_settings_form, external_service_form, external_service_functions_form, factor_email\form\email, feedback_captcha_form, feedback_edit_create_template_form, feedback_edit_use_template_form, feedback_import_form, feedback_info_form, feedback_item_form, feedback_label_form, feedback_multichoice_form, feedback_multichoicerated_form, feedback_numeric_form, feedback_textarea_form, feedback_textfield_form, filter_local_settings_form, forumreport_summary\form\dates_filter_form, grade_export_form, grade_import_form, grade_import_form, grade_import_mapping_form, gradeimport_direct_import_form, gradeimport_direct_mapping_form, grader_report_preferences_form, gradereport_history\filter_form, grading_search_template_form, gradingform_guide_editguide, gradingform_rubric_editrubric, group_form, grouping_form, groups_import_form, import_outcomes_form, key_form, key_form, lesson_add_page_form_base, lesson_display_answer_form_essay, lesson_display_answer_form_matching, lesson_display_answer_form_multichoice_multianswer, lesson_display_answer_form_multichoice_singleanswer, lesson_display_answer_form_numerical, lesson_display_answer_form_shortanswer, lesson_display_answer_form_truefalse, lesson_import_form, lesson_override_form, lesson_page_without_answers, login_change_password_form, login_forgot_password_form, login_forgot_password_form, login_set_password_form, login_signup_form, mnet_profile_form, mnet_review_host_form, mnet_services_form, mnet_simple_host_form, mod_assign_batch_set_allocatedmarker_form, mod_assign_batch_set_marking_workflow_state_form, mod_assign_confirm_submission_form, mod_assign_extension_form, mod_assign_grade_form, mod_assign_grading_batch_operations_form, mod_assign_grading_options_form, mod_assign_mod_form, mod_assign_quick_grading_form, mod_assign_submission_form, mod_bigbluebuttonbn\form\guest_add, mod_bigbluebuttonbn\form\guest_login, mod_bigbluebuttonbn_mod_form, mod_book_mod_form, mod_chat_mod_form, mod_choice_mod_form, mod_data\form\import_presets, mod_data\form\save_as_preset, mod_data_export_form, mod_data_import_form, mod_data_mod_form, mod_feedback\form\create_template_form, mod_feedback\form\use_template_form, mod_feedback_complete_form, mod_feedback_course_map_form, mod_feedback_course_select_form, mod_feedback_mod_form, mod_feedback_use_templ_form, mod_folder_edit_form, mod_folder_mod_form, mod_forum\form\export_form, mod_forum_mod_form, mod_forum_post_form, mod_forum_prune_form, mod_glossary_entry_form, mod_glossary_import_form, mod_glossary_mod_form, mod_h5pactivity_mod_form, mod_imscp_mod_form, mod_label_mod_form, mod_lesson_mod_form, mod_lti_edit_types_form, mod_lti_mod_form, mod_lti_register_types_form, mod_page_mod_form, mod_quiz\form\add_random_form, mod_quiz\form\edit_override_form, mod_quiz\form\preflight_check_form, mod_quiz\form\randomquestion_form, mod_quiz\local\reports\attempts_report_options_form, mod_quiz_mod_form, mod_resource_mod_form, mod_scorm_mod_form, mod_scorm_report_interactions_settings, mod_scorm_report_objectives_settings, mod_scorm_report_settings, mod_survey_mod_form, mod_url_mod_form, mod_wiki_comments_form, mod_wiki_create_form, mod_wiki_edit_form, mod_wiki_filesedit_form, mod_wiki_mod_form, mod_workshop_mod_form, note_edit_form, portfolio_admin_form, portfolio_export_form, portfolio_instance_select, portfolio_user_form, profiling_import_form, qbank_exportquestions\form\export_form, qbank_importquestions\form\question_import_form, qbank_managecategories\form\question_category_edit_form, qbank_managecategories\form\question_move_form, qbank_previewquestion\form\preview_options_form, qbank_tagquestion\form\tags_form, qtype_random_edit_form, question_dataset_dependent_definitions_form, question_dataset_dependent_items_form, question_edit_form, quiz_grading_settings_form, quiz_statistics_settings_form, recent_form, reject_request_form, report_eventlist_filter_form, report_outline\filter_form, repository_instance_form, repository_type_form, steps_definitions_form, switchrole_form, tag_edit_form, tiny_media\form\manage_files_form, tool_admin_presets\form\continue_form, tool_admin_presets\form\export_form, tool_admin_presets\form\import_form, tool_admin_presets\form\load_form, tool_analytics\output\form\edit_model, tool_analytics\output\form\import_model, tool_brickfield\form\registration_form, tool_capability_settings_form, tool_cohortroles\form\assign_role_cohort, tool_componentlibrary\local\examples\formelements\example, tool_customlang\form\export, tool_customlang\form\import, tool_customlang_filter_form, tool_dataprivacy\form\contactdpo, tool_dataprivacy\form\exportfilter_form, tool_filetypes_form, tool_generator_make_course_form, tool_generator_make_testplan_form, tool_httpsreplace\form, tool_installaddon_installfromzip_form, tool_licensemanager\form\edit_license, tool_lp\form\template_cohorts, tool_lp\form\template_plans, tool_lpimportcsv\form\export, tool_lpimportcsv\form\import, tool_lpimportcsv\form\import_confirm, tool_lpmigrate\form\migrate_framework, tool_messageinbound_edit_handler_form, tool_mfa\local\form\login_form, tool_mfa\local\form\reset_factor, tool_mfa\local\form\revoke_factor_form, tool_mfa\local\form\setup_factor_form, tool_monitor\rule_form, tool_policy\form\accept_policy, tool_policy\form\policydoc, tool_replace_form, tool_task_edit_scheduled_task_form, tool_uploadcourse_base_form, tool_uploadcourse_step1_form, tool_uploadcourse_step2_form, tool_usertours\local\forms\editstep, tool_usertours\local\forms\edittour, tool_usertours\local\forms\importtour, user_active_filter_form, user_add_filter_form, user_bulk_action_form, user_bulk_cohortadd_form, user_bulk_form, user_edit_editor_form, user_edit_form, user_edit_forum_form, user_edit_language_form, user_editadvanced_form, user_message_form, webservice_test_client_base_form, webservice_test_client_form, workshop_assessment_form, workshop_edit_strategy_form, workshop_evaluation_settings_form, workshop_feedbackauthor_form, workshop_feedbackreviewer_form, workshop_random_allocator_form, workshop_scheduled_allocator_form, and workshop_submission_form.
moodleform::definition_after_data | ( | ) |
Dummy stub method - override if you need to setup the form depending on current values.
This method is called after definition(), data submission and set_data(). All form setup that is dependent on form values should go in here.
Reimplemented in admin_uploaduser_form2, backup_confirmation_form, base_moodleform, blog_edit_external_form, book_chapter_edit_form, cohort_edit_form, cohort_upload_form, core_calendar\local\event\forms\managesubscriptions, core_completion_edit_base_form, core_grades\form\add_category, core_user\form\calendar_form, core_user\form\profile_field_form, course_edit_form, edit_calculation_form, edit_category_form, edit_grade_form, edit_item_form, edit_outcome_form, edit_outcomeitem_form, edit_scale_form, editsection_form, external_service_form, gradingform_guide_editguide, gradingform_rubric_editrubric, group_form, grouping_form, login_signup_form, mod_bigbluebuttonbn_mod_form, mod_forum_mod_form, mod_glossary_mod_form, mod_lti_edit_types_form, mod_resource_mod_form, mod_workshop_mod_form, moodleform_mod, question_edit_form, report_outline\filter_form, tool_mfa\local\form\login_form, tool_mfa\local\form\setup_factor_form, tool_uploadcourse_step2_form, user_edit_form, user_edit_language_form, and user_editadvanced_form.
moodleform::display | ( | ) |
Print html form.
Reimplemented in base_moodleform, cohort_upload_form, and mod_feedback_complete_form.
MoodleQuickForm::enable_form_change_checker | ( | ) |
If you have called disable_form_change_checker() then you can use this method to re-enable it.
It is enabled by default, so normally you don't need to call this.
MoodleQuickForm::exportValues | ( | $elementList = null | ) |
export submitted values
string | $elementList | list of elements in form |
array |
moodleform::filter_shown_headers | ( | array | $shownonly | ) |
Use this method to indicate that the fieldsets should be shown as expanded and all other fieldsets should be hidden.
The method is applicable to header elements only.
array | $shownonly | array of header element names |
void |
MoodleQuickForm::filter_shown_headers | ( | array | $shownonly | ) |
Use this method to indicate that the fieldsets should be shown and expanded and all other fieldsets should be hidden.
The method is applicable to header elements only.
array | $shownonly | array of header element names |
void |
moodleform::focus | ( | $name = NULL | ) |
To autofocus on first form element or first element with error.
string | $name | if this is set then the focus is forced to a field with this name |
string | javascript to select form element with first error or first element if no errors. Use this as a parameter when calling print_header |
if($CFG->debugdeveloper) moodle_page form_init_date_js | ( | ) |
Initalize javascript for date type form element.
@staticvar bool $done make sure it gets initalize once. $PAGE
|
protected |
Returns an element of multi-dimensional array given the list of keys.
Example: $array['a']['b']['c'] = 13; $v = $this->get_array_value_by_keys($array, ['a', 'b', 'c']);
Will result it $v==13
array | $array | |
array | $keys |
mixed | returns null if keys not present |
moodleform::get_data | ( | ) |
Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data.
note: $slashed param removed
stdClass|null | submitted data; NULL if not valid or not submitted or cancelled |
Reimplemented in admin_uploaduser_form2, block_edit_form, core\hub\site_registration_form, core_badges\form\external_backpack, core_completion_edit_base_form, editsection_form, feedback_item_form, feedback_multichoice_form, feedback_multichoicerated_form, feedback_numeric_form, feedback_textarea_form, feedback_textfield_form, grade_export_form, gradingform_guide_editguide, gradingform_rubric_editrubric, lesson_add_page_form_numerical, mod_forum_mod_form, mod_lti_edit_types_form, moodleform_mod, tool_filetypes_form, tool_policy\form\policydoc, and tool_usertours\local\forms\editstep.
|
protected |
Get draft files of a form element This is a protected method which will be used only inside moodleforms.
string | $elname | name of element |
array|bool|null |
moodleform::get_file_content | ( | $elname | ) |
Get content of uploaded file.
string | $elname | name of file upload element |
string|bool | false in case of failure, string if ok |
|
protected |
It should returns unique identifier for the form.
Currently it will return class name, but in case two same forms have to be rendered on same page then override function to get unique form identifier. e.g This is used on multiple self enrollments page.
string | form identifier. |
Reimplemented in core_completion_defaultedit_form, enrol_self_enrol_form, and mod_assign_grade_form.
|
static |
Returns a JS module definition for the mforms JS.
array |
Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.
moodleform::get_new_filename | ( | $elname = null | ) |
Returns name of uploaded file.
string | $elname | first element if null |
string|bool | false in case of failure, string if ok |
moodleform::get_submitted_data | ( | ) |
Return submitted data without validation or NULL if there is no submitted data.
note: $slashed param removed
stdClass|null | submitted data; NULL if not submitted |
Reimplemented in lesson_add_page_form_numerical.
MoodleQuickForm::getAdvancedHTML | ( | ) |
Returns HTML for advanced elements.
string |
MoodleQuickForm::getCleanedValue | ( | $value, | |
$type ) |
Return the cleaned value using the passed type(s).
mixed | $value | value that has to be cleaned. |
int | array | $type | constant value to use to clean (PARAM_...), typically returned by self::getCleanType(). |
mixed | cleaned up value. |
MoodleQuickForm::getCleanType | ( | $elementname, | |
$value, | |||
$default = PARAM_RAW ) |
Return the type(s) to use to clean an element.
In the case where the element has an array as a value, we will try to obtain a type defined for that specific key, and recursively until done.
This method does not work reverse, you cannot pass a nested element and hoping to fallback on the clean type of a parent. This method intends to be used with the main element, which will generate child types if needed, not the other way around.
Example scenario:
You have defined a new repeated element containing a text field called 'foo'. By default there will always be 2 occurence of 'foo' in the form. Even though you've set the type on 'foo' to be PARAM_INT, for some obscure reason, you want the first value of 'foo', to be PARAM_FLOAT, which you set using setType: $mform->setType('foo[0]', PARAM_FLOAT).
Now if you call this method passing 'foo', along with the submitted values of 'foo': array(0 => '1.23', 1 => '10'), you will get an array telling you that the key 0 is a FLOAT and 1 is an INT. If you had passed 'foo[1]', along with its value '10', you would get the default clean type returned (param $default).
string | $elementname | name of the element. |
mixed | $value | value that should be cleaned. |
int | $default | default constant value to be returned (PARAM_...) |
string|array | constant value or array of constant values (PARAM_...) |
MoodleQuickForm::getReqHTML | ( | ) |
Returns HTML for required elements.
string |
MoodleQuickForm::getShowAdvanced | ( | ) |
This function has been deprecated.
Show advanced has been replaced by "Show more.../Show less..." in the shortforms javascript module.
bool | (Always false) |
MoodleQuickForm::getValidationScript | ( | ) |
Returns the client side validation script.
The code here was copied from HTML_QuickForm_DHTMLRulesTableless who copied it from HTML_QuickForm and slightly modified to run rules per-element Needed to override this because of an error with client side validation of grouped elements.
string | Javascript to perform validation, empty string if no 'client' rules were added |
moodleform::init_javascript_enhancement | ( | $element, | |
$enhancement, | |||
array | $options = array(), | ||
array | $strings = null ) |
Adds an initialisation call for a standard JavaScript enhancement.
This function is designed to add an initialisation call for a JavaScript enhancement that should exist within javascript-static M.form.init_{enhancementname}.
Current options:
string | element | $element | form element for which Javascript needs to be initalized |
string | $enhancement | which init function should be called |
array | $options | options passed to javascript |
array | $strings | strings for javascript |
moodleform::is_cancelled | ( | ) |
Return true if a cancel button has been pressed resulting in the form being submitted.
bool | true if a cancel button has been pressed |
Reimplemented in base_moodleform.
MoodleQuickForm::is_dirty | ( | ) |
Is the form currently set to dirty?
boolean | Initial dirty state. |
MoodleQuickForm::is_form_change_checker_enabled | ( | ) |
bool | whether this form should automatically initialise formchangechecker for itself. |
MoodleQuickForm::is_shown | ( | string | $headername | ) |
Use this method to check if the fieldsets could be shown.
The method is applicable to header elements only.
string | $headername | header element name to check in the shown only elements array. |
void |
moodleform::is_submitted | ( | ) |
Check that form was submitted.
Does not check validity of submitted data.
bool | true if form properly submitted |
moodleform::is_validated | ( | ) |
Check that form data is valid.
You should almost always use this, rather than validate_defined_fields
bool | true if form data valid |
|
static |
Used by tests to simulate submitted form data submission via AJAX.
For form fields where no data is submitted the default for that field as set by set_data or setDefault will be passed to get_data.
This method sets $_POST or $_GET and $_FILES with the data supplied. Our unit test code empties all these global arrays after each test.
array | $simulatedsubmitteddata | An associative array of form values (same format as $_POST). |
array | $simulatedsubmittedfiles | An associative array of files uploaded (same format as $_FILES). Can be omitted. |
string | $method | 'post' or 'get', defaults to 'post'. |
null | $formidentifier | the default is to use the class name for this class but you may need to provide a different value here for some forms that are used more than once on the same page. |
array | array to pass to form constructor as $ajaxdata |
Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.
|
static |
Used by tests to generate valid submit keys for moodle forms that are submitted with ajax data.
moodle_exception | If called outside unit test environment |
array | $data | Existing form data you wish to add the keys to. |
array |
Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.
|
static |
Used by tests to simulate submitted form data submission from the user.
For form fields where no data is submitted the default for that field as set by set_data or setDefault will be passed to get_data.
This method sets $_POST or $_GET and $_FILES with the data supplied. Our unit test code empties all these global arrays after each test.
array | $simulatedsubmitteddata | An associative array of form values (same format as $_POST). |
array | $simulatedsubmittedfiles | An associative array of files uploaded (same format as $_FILES). Can be omitted. |
string | $method | 'post' or 'get', defaults to 'post'. |
null | $formidentifier | the default is to use the class name for this class but you may need to provide a different value here for some forms that are used more than once on the same page. |
Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.
moodleform::moodleform | ( | $action = null, | |
$customdata = null, | |||
$method = 'post', | |||
$target = '', | |||
$attributes = null, | |||
$editable = true ) |
MoodleQuickForm::MoodleQuickForm | ( | $formName, | |
$method, | |||
$action, | |||
$target = '', | |||
$attributes = null ) |
moodleform::no_submit_button_pressed | ( | ) |
Checks if button pressed is not for submitting the form.
@staticvar bool $nosubmit keeps track of no submit button
bool |
moodleform::optional_param | ( | $name, | |
$default, | |||
$type ) |
Checks if a parameter was passed in the previous form submission.
string | $name | the name of the page parameter we want, for example 'id' or 'element[sub][13]' |
mixed | $default | the default value to return if nothing is found |
string | $type | expected type of parameter |
mixed |
MoodleQuickForm::optional_param | ( | $name, | |
$default, | |||
$type ) |
Checks if a parameter was passed in the previous form submission.
string | $name | the name of the page parameter we want |
mixed | $default | the default value to return if nothing is found |
string | $type | expected type of parameter |
mixed |
pear_handle_error | ( | $error | ) |
Callback called when PEAR throws an error.
PEAR_Error | $error |
|
protected |
This is a bit of a hack, and it duplicates the code in HTML_QuickForm_element\_prepareValue, but I could not think of a way or reliably calling that code.
(Think about date selectors, for example.)
string | $name | the element name. |
mixed | $value | the fixed value to set. |
mixed | the appropriate array to add to the $unfiltered array. |
moodleform::render | ( | ) |
Renders the html form (same as display, but returns the result).
Note that you can only output this rendered result once per page, as it contains IDs which must be unique.
string | HTML code for the form |
moodleform::repeat_elements | ( | $elementobjs, | |
$repeats, | |||
$options, | |||
$repeathiddenname, | |||
$addfieldsname, | |||
$addfieldsno = 5, | |||
$addstring = null, | |||
$addbuttoninside = false, | |||
$deletebuttonname = '' ) |
Method to add a repeating group of elements to a form.
array | $elementobjs | Array of elements or groups of elements that are to be repeated |
int | $repeats | no of times to repeat elements initially |
array | $options | a nested array. The first array key is the element name. the second array key is the type of option to set, and depend on that option, the value takes different forms. 'default' - default value to set. Can include '{no}' which is replaced by the repeat number. 'type' - PARAM_* type. 'helpbutton' - array containing the helpbutton params. 'disabledif' - array containing the disabledIf() arguments after the element name. 'rule' - array containing the addRule arguments after the element name. 'expanded' - whether this section of the form should be expanded by default. (Name be a header element.) 'advanced' - whether this element is hidden by 'Show more ...'. |
string | $repeathiddenname | name for hidden element storing no of repeats in this form |
string | $addfieldsname | name for button to add more fields |
int | $addfieldsno | how many fields to add at a time |
string | $addstring | name of button, {no} is replaced by no of blanks that will be added. |
bool | $addbuttoninside | if true, don't call closeHeaderBefore($addfieldsname). Default false. |
string | $deletebuttonname | if specified, treats the no-submit button with this name as a "delete element" button in each of the elements |
int | no of repeats of element in this page |
moodleform::repeat_elements_fix_clone | ( | $i, | |
$elementclone, | |||
& | $namecloned ) |
Helper used by repeat_elements().
int | $i | the index of this element. |
HTML_QuickForm_element | $elementclone | |
array | $namecloned | array of names |
moodleform::save_file | ( | $elname, | |
$pathname, | |||
$override = false ) |
Save file to standard filesystem.
string | $elname | name of element |
string | $pathname | full path name of file |
bool | $override | override file if exists |
bool | success |
moodleform::save_files | ( | $destination | ) |
Save verified uploaded files into directory.
Upload process can be customised from definition()
string | $destination | path where file should be stored |
bool | Always false |
moodleform::save_stored_file | ( | $elname, | |
$newcontextid, | |||
$newcomponent, | |||
$newfilearea, | |||
$newitemid, | |||
$newfilepath = '/', | |||
$newfilename = null, | |||
$overwrite = false, | |||
$newuserid = null ) |
Save file to local filesystem pool.
string | $elname | name of element |
int | $newcontextid | id of context |
string | $newcomponent | name of the component |
string | $newfilearea | name of file area |
int | $newitemid | item id |
string | $newfilepath | path of file where it get stored |
string | $newfilename | use specified filename, if not specified name of uploaded file used |
bool | $overwrite | overwrite file if exists |
int | $newuserid | new userid if required |
mixed | stored_file object or false if error; may throw exception if duplicate found |
moodleform::save_temp_file | ( | $elname | ) |
Returns a temporary file, do not forget to delete after not needed any more.
string | $elname | name of the elmenet |
string|bool | either string or false |
moodleform::set_data | ( | $default_values | ) |
Load in existing data as form defaults.
Usually new entry defaults are stored directly in form definition (new entry form); this function is used to load in data where values already exist and data is being edited (edit entry form).
note: $slashed param removed
stdClass | array | $default_values | object or array of default values |
Reimplemented in block_edit_form, block_html_edit_form, cache_definition_sharing_form, core_badges\form\badge, editsection_form, feedback_multichoice_form, feedback_multichoicerated_form, lesson_add_page_form_numerical, mod_lti_mod_form, mod_quiz\form\randomquestion_form, mod_scorm_mod_form, moodleform_mod, qbank_managecategories\form\question_category_edit_form, qtype_missingtype_edit_form, qtype_multianswer_edit_form, qtype_random_edit_form, question_dataset_dependent_items_form, question_edit_form, tool_filetypes_form, and tool_usertours\local\forms\editstep.
moodleform::set_display_vertical | ( | ) |
Set display mode for the form when labels take full width of the form and above the elements even on big screens.
Useful for forms displayed inside modals or in narrow containers
moodleform::set_initial_dirty_state | ( | $state = false | ) |
Set the initial 'dirty' state of the form.
bool | $state |
MoodleQuickForm::set_initial_dirty_state | ( | $state = false | ) |
Set the initial 'dirty' state of the form.
bool | $state |
MoodleQuickForm::set_sticky_footer | ( | ?string | $elementname | ) |
Use this method to indicate an element to display as a sticky footer.
Only one page element can be displayed in the sticky footer. To render more than one element use addGroup to create a named group.
string | null | $elementname | group or element name (not the element name of something inside a group). |
MoodleQuickForm::setAdvanced | ( | $elementName, | |
$advanced = true ) |
Use this method to indicate an element in a form is an advanced field.
If items in a form are marked as advanced then 'Hide/Show Advanced' buttons will automatically be displayed in the form so the user can decide whether to display advanced form controls.
If you set a header element to advanced then all elements it contains will also be set as advanced.
string | $elementName | group or element name (not the element name of something inside a group). |
bool | $advanced | default true sets the element to advanced. False removes advanced mark. |
MoodleQuickForm::setConstant | ( | $elname, | |
$value ) |
Set constant value not overridden by _POST or _GET note: this does not work for complex names with [] :-(.
string | $elname | name of element |
mixed | $value |
MoodleQuickForm::setDefault | ( | $elementName, | |
$defaultValue ) |
Initializes a default form value.
Used to specify the default for a new entry where no data is loaded in using moodleform\set_data()
note: $slashed param removed
string | $elementName | element name |
mixed | $defaultValue | values for that element name |
MoodleQuickForm::setDisableShortforms | ( | $disable = true | ) |
Use this method to indicate that the form will not be using shortforms.
boolean | $disable | default true, controls if the shortforms are disabled. |
MoodleQuickForm::setExpanded | ( | $headername, | |
$expanded = true, | |||
$ignoreuserstate = false ) |
Use this method to indicate that the fieldset should be shown as expanded.
The method is applicable to header elements only.
string | $headername | header element name |
boolean | $expanded | default true sets the element to expanded. False makes the element collapsed. |
boolean | $ignoreuserstate | override the state regardless of the state it was on when the form was submitted. |
void |
MoodleQuickForm::setForceLtr | ( | $elementname, | |
$value = true ) |
Set an element to be forced to flow LTR.
The element must exist and support this functionality. Also note that when setting the type of a field (} we try to guess the whether the field should be force to LTR or not. Make sure you're always calling this method last. string $elementname The element name. bool $value When false, disables force LTR, else enables it.
MoodleQuickForm::setShowAdvanced | ( | $showadvancedNow = null | ) |
This function has been deprecated.
Show advanced has been replaced by "Show more.../Show less..." in the shortforms javascript module.
bool | $showadvancedNow | if true will show advanced elements. |
MoodleQuickForm::setType | ( | $elementname, | |
$paramtype ) |
Should be used for all elements of a form except for select, radio and checkboxes which clean their own data.
string | $elementname | |
string | $paramtype | defines type of data contained in element. Use the constants PARAM_*. lib/moodlelib.php for defined parameter types |
MoodleQuickForm::setTypes | ( | $paramtypes | ) |
This can be used to set several types at once.
array | $paramtypes | types of parameters. |
MoodleQuickForm::updateSubmission | ( | $submission, | |
$files ) |
Updates submitted values.
array | $submission | submitted values |
array | $files | list of files |
moodleform::validate_defined_fields | ( | $validateonnosubmit = false | ) |
Validate the form.
You almost always want to call is_validated instead of this because it calls definition_after_data first, before validating the form, which is what you want in 99% of cases.
This is provided as a separate function for those special cases where you want the form validated before definition_after_data is called for example, to selectively add new elements depending on a no_submit_button press, but only when the form is valid when the no_submit_button is pressed,
bool | $validateonnosubmit | optional, defaults to false. The default behaviour is NOT to validate the form when a no submit button has been pressed. pass true here to override this behaviour |
bool | true if form data valid |
|
protected |
Internal method.
Validates filepicker and filemanager files if they are set as required fields. Also, sets the error message if encountered one.
bool|array | with errors |
moodleform::validation | ( | $data, | |
$files ) |
Dummy stub method - override if you needed to perform some extra validation.
If there are errors return array of errors ("fieldname"=>"error message"), otherwise true if ok.
Server side rules do not work for uploaded files, implement serverside rules here if needed.
array | $data | array of ("fieldname"=>value) of submitted data |
array | $files | array of uploaded files "element_name"=>tmp_file_path |
array | of "element_name"=>"error_description" if there are errors, or an empty array if everything is OK (true allowed for backwards compatibility too). |
Reimplemented in admin_uploaduser_form2, alignment_form, assign_override_form, autogroup_form, backup_confirmation_form, blog_edit_external_form, blog_edit_form, booktool_importhtml_form, cache_definition_sharing_form, cache_lock_form, cachestore_addinstance_form, cohort_edit_form, cohort_upload_form, core\hub\site_registration_form, core_admin\form\purge_caches, core_admin\form\testoutgoingmailconf_form, core_backup\output\copy_form, core_badges\form\backpack, core_badges\form\badge, core_badges\form\external_backpack, core_calendar\local\event\forms\create, core_calendar\local\event\forms\managesubscriptions, core_completion_bulkedit_form, core_completion_edit_base_form, core_contentbank\form\upload_files, core_course_deletecategory_form, core_course_editcategory_form, core_customfield\field_config_form, core_grades\form\add_category, core_grades\form\add_item, core_grades\form\add_outcome, core_reportbuilder\form\audience, core_reportbuilder\form\report, core_reportbuilder\form\schedule, core_role_preset_form, core_user\form\contactsitesupport_form, core_user\form\private_files, core_user\form\profile_category_form, core_user\form\profile_field_form, core_webservice\token_form, course_completion_form, course_edit_form, course_request_form, course_reset_form, database_transfer_form, edit_calculation_form, edit_category_form, edit_criteria_form, edit_item_form, edit_outcome_form, edit_outcomeitem_form, edit_relatedbadge_form, edit_scale_form, editsection_form, endorsement_form, enrol_guest_enrol_form, enrol_instance_edit_form, enrol_lti\local\ltiadvantage\form\deployment_form, enrol_lti\local\ltiadvantage\form\platform_registration_form, enrol_manual_enrol_users_form, enrol_self_enrol_form, enrol_user_enrolment_form, event_form, external_service_form, factor_email\form\email, feedback_edit_create_template_form, grade_import_form, grader_report_preferences_form, gradingform_guide_editguide, gradingform_rubric_editrubric, group_form, grouping_form, lesson_import_form, lesson_override_form, login_change_password_form, login_forgot_password_form, login_set_password_form, login_signup_form, mnet_review_host_form, mnet_simple_host_form, mod_assign_batch_set_marking_workflow_state_form, mod_assign_extension_form, mod_assign_grade_form, mod_assign_mod_form, mod_bigbluebuttonbn\form\guest_add, mod_bigbluebuttonbn\form\guest_login, mod_bigbluebuttonbn_mod_form, mod_choice_mod_form, mod_data\form\save_as_preset, mod_data_mod_form, mod_feedback_mod_form, mod_folder_mod_form, mod_forum_mod_form, mod_forum_post_form, mod_glossary_entry_form, mod_h5pactivity_mod_form, mod_imscp_mod_form, mod_label_mod_form, mod_lesson_mod_form, mod_lti_edit_types_form, mod_quiz\form\add_random_form, mod_quiz\form\edit_override_form, mod_quiz\form\preflight_check_form, mod_quiz\local\reports\attempts_report_options_form, mod_quiz_mod_form, mod_resource_mod_form, mod_scorm_mod_form, mod_url_mod_form, mod_workshop_mod_form, moodleform_mod, portfolio_admin_form, portfolio_export_form, portfolio_user_form, qbank_importquestions\form\question_import_form, qbank_managecategories\form\question_category_edit_form, qtype_calculated_edit_form, qtype_calculatedmulti_edit_form, qtype_calculatedsimple_edit_form, qtype_ddimageortext_edit_form, qtype_ddmarker_edit_form, qtype_essay_edit_form, qtype_gapselect_edit_form_base, qtype_match_edit_form, qtype_missingtype_edit_form, qtype_multianswer_edit_form, qtype_multichoice_edit_form, qtype_numerical_edit_form, qtype_random_edit_form, qtype_randomsamatch_edit_form, qtype_shortanswer_edit_form, question_dataset_dependent_definitions_form, question_dataset_dependent_items_form, question_edit_form, quiz_responses_settings_form, repository_instance_form, repository_type_form, tag_edit_form, tool_analytics\output\form\edit_model, tool_dataprivacy\form\exportfilter_form, tool_filetypes_form, tool_generator_make_course_form, tool_generator_make_testplan_form, tool_installaddon_installfromzip_form, tool_licensemanager\form\edit_license, tool_lpmigrate\form\migrate_framework, tool_mfa\local\form\login_form, tool_mfa\local\form\reset_factor, tool_mfa\local\form\setup_factor_form, tool_monitor\rule_form, tool_policy\form\policydoc, tool_replace_form, tool_task_edit_scheduled_task_form, tool_uploadcourse_step2_form, tool_usertours\local\forms\editstep, user_edit_form, user_editadvanced_form, workshop_edit_strategy_form, workshop_feedbackauthor_form, workshop_feedbackreviewer_form, workshop_random_allocator_form, workshop_rubric_assessment_form, and workshop_submission_form.
array MoodleQuickForm::$_advancedElements = array() |
Array whose keys are element names.
If the key exists this is a advanced element
array MoodleQuickForm::$_collapsibleElements = array() |
Array whose keys are element names and values are the desired collapsible state.
True for collapsed, False for expanded. If not present, set to default in self::accept().
string MoodleQuickForm::$_pageparams = '' |
String with the html for hidden params passed in as part of a moodle_url object for the action.
Output in the form.
|
protected |
Array whose keys are the only elements to be shown.
Rest of the elements that are not in this array will be hidden.
|
protected |
The form element to render in the sticky footer, if any.
$_stickyfooterelement
if (!defined( 'MOODLE_INTERNAL')) global $CFG |
Button form element.
Contains HTML class for a button type element
global $CFG |
Group of date input element.
Contains class for a group of elements used to input a date.
global $CFG |
Group of date and time input element.
Contains class for a group of elements used to input a date and time.
global $CFG |
Duration form element.
Contains class to create length of time for element.
global $CFG |
Editor input element.
Contains class to create preffered editor form element
global $CFG |
FileManager form element.
Contains HTML class for a filemanager form element
global $CFG |
Filepicker form element.
Contains HTML class for a single filepicker form element
global $CFG |
Advance grading form element.
Element-container for advanced grading custom input
global $CFG |
Drop down form element to select the grade.
Contains HTML class for a drop down element to select the grade for an activity, used in mod update form
global $CFG |
Drop down form element to select visibility in an activity mod update form.
Contains HTML class for a drop down element to select visibility in an activity mod update form
if (!defined( 'MOODLE_INTERNAL')) global $CFG |
Password type form element with unmask option.
Contains HTML class for a password type element with unmask option
global $CFG |
Drop down for question categories.
Contains HTML class for a drop down element to select a question category.
global $CFG |
Yes/No drop down type form element.
Contains HTML class for a simple yes/ no drop down element
const EDITOR_UNLIMITED_FILES -1 |
setup.php includes our hacked pear libs first
EDITOR_UNLIMITED_FILES - hard-coded value for the 'maxfiles' option