Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_form

Namespaces

namespace  core_form
  
 
namespace  core_form\external
  
 
namespace  core_form\privacy
  
 

Classes

class  behat_core_form
 Steps definitions related to core_form. More...
 
class  behat_editor_textarea
 
class  behat_form_autocomplete
 Auto complete form field. More...
 
class  behat_form_availability
 Availability form field class. More...
 
class  behat_form_checkbox
 Checkbox form field. More...
 
class  behat_form_date
 Date form field. More...
 
class  behat_form_date_time
 Date time form field. More...
 
class  behat_form_editor
 Moodle editor field. More...
 
class  behat_form_field
 Representation of a form field. More...
 
class  behat_form_filemanager
 File manager form field. More...
 
class  behat_form_group
 Class to re-guess the field type as grouped fields can have different field types. More...
 
class  behat_form_inplaceeditable
 Custom interaction with inplace editable elements. More...
 
class  behat_form_inplaceeditable_select
 
class  behat_form_modvisible
 Allows interaction with fmodvisible form fields. More...
 
class  behat_form_passwordunmask
 Allows interaction with passwordunmask form fields. More...
 
class  behat_form_radio
 Radio input form field. More...
 
class  behat_form_select
 Single select form field. More...
 
class  behat_form_select_menu
 
class  behat_form_selectyesno
 Allows interaction with selectyesno form fields. More...
 
class  behat_form_text
 Class for test-based fields. More...
 
class  behat_form_textarea
 Textarea field class. More...
 
class  core_form\dynamic_form
 
class  core_form\external
 Implements the external functions provided by the core_form subsystem. More...
 
class  core_form\external\dynamic_form
 
class  core_form\filetypes_util
 Utility class for handling with file types in the forms. More...
 
class  core_form\privacy\provider
 Implements the privacy API for the core_form subsystem. More...
 
class  core_form\util
 General utility class for form-related methods. More...
 
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
 HTML class for an advcheckbox type element. More...
 
class  MoodleQuickForm_autocomplete
 Autocomplete as you type form element. More...
 
class  MoodleQuickForm_button
 HTML class for a button type element. More...
 
class  MoodleQuickForm_cancel
 HTML class for a submit cancel type element. More...
 
class  MoodleQuickForm_checkbox
 HTML class for a checkbox type element. More...
 
class  MoodleQuickForm_cohort
 Form field type for choosing a cohort. More...
 
class  MoodleQuickForm_course
 Form field type for choosing a course. 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_defaultcustom
 Creates an element with a dropdown Default/Custom and an input for the value (text or date_selector) 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
 HTML class for a form element group. More...
 
class  MoodleQuickForm_header
 Header form element. More...
 
class  MoodleQuickForm_hidden
 Hidden type form element. More...
 
class  MoodleQuickForm_listing
 The listing element is a simple customizable "select" without the input type=select. 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_searchableselector
 Form field type for selecting from a list of options. 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 element. More...
 
class  MoodleQuickForm_submit
 submit type form element More...
 
class  MoodleQuickForm_tags
 Form field type for editing tags. 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 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.
 
 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)
 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::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 ()
 
 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::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::$_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
 
global $CFG
 
if(!defined('MOODLE_INTERNAL')) global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
if(!defined('MOODLE_INTERNAL')) global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global core_form::$CFG
 
bool MoodleQuickForm::$clientvalidation = false
 Whether the form contains any client-side validation or not.
 
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
 
 if (!defined( 'MOODLE_INTERNAL'))
 

Detailed Description

Function Documentation

◆ __construct() [1/2]

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

Parameters
mixed$actionthe 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$customdataif 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$methodif you set this to anything other than 'post' then _GET and _POST will be merged and used as incoming data to the form.
string$targettarget 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$attributesyou 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$ajaxformdataForms submitted via ajax, must pass their data here, instead of relying on _GET and _POST.

Reimplemented in assign_override_form, feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.

◆ __construct() [2/2]

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

Parameters
string$formNameForm's name.
string$methodForm's method defaults to 'POST'
string | moodle_url$actionForm's action
string$target(optional)Form's target defaults to none
mixed$attributes(optional)Extra attributes for <form> tag
array$ajaxformdataForms submitted via ajax, must pass their data here, instead of relying on _GET and _POST.

◆ _get_post_params()

moodleform::_get_post_params ( )
protected

Internal method - should not be used anywhere.

Deprecated
since 2.6
Return values
array\$_POST,.

◆ _process_submission()

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.

Parameters
string$methodname of the method which alters submitted data

◆ _validate_files()

moodleform::_validate_files ( & $files)

Internal method.

Validates all old-style deprecated uploaded files. The new way is to upload files via repository api.

Parameters
array$fileslist of files to be validated
Return values
bool|arraySuccess or an array of errors

◆ accept()

MoodleQuickForm::accept ( & $renderer)

Accepts a renderer.

Parameters
HTML_QuickForm_Renderer$rendererAn HTML_QuickForm_Renderer object

◆ add_action_buttons()

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().

Parameters
bool$cancelwhether to show cancel button, default true
string$submitlabellabel for submit button, defaults to get_string('savechanges')

Reimplemented in core_badges\form\backpack, core_contentbank\form\edit_content, and tool_uploadcourse_step2_form.

◆ add_checkbox_controller()

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.

Parameters
int$groupidThe id of the group of advcheckboxes this element controls
string$textThe text of the link. Defaults to selectallornone ("select all/none")
array$attributesassociative array of HTML attributes
int$originalValueThe original general state of the checkboxes before the user first clicks this element

◆ addAdvancedStatusElement()

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.

Parameters
string$headerNameheader element name.
boolean$showmoredefault false sets the advanced elements to be hidden.

◆ addGroupRule()

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.

Parameters
string$groupForm group name
array | string$arg1Array 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$resetClient-side: whether to reset the element's value to its original state if validation failed.

◆ addHelpButton()

MoodleQuickForm::addHelpButton ( $elementname,
$identifier,
$component = 'moodle',
$linktext = '',
$suppresscheck = false )

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

Since
Moodle 2.0
Parameters
string$elementnamename of the element to add the item to
string$identifierhelp string identifier without _help suffix
string$componentcomponent name to look the help string in
string$linktextoptional text to display next to the icon
bool$suppresscheckset to true if the element may not exist

◆ addRule()

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.

Parameters
string$elementForm element name
string | null$messageMessage to display for invalid data
string$typeRule type, use getRegisteredRules() to get types
mixed$format(optional)Required for extra rule data
string$validation(optional)Where to perform validation: "server", "client"
bool$resetClient-side validation: reset the form element to its original value if there is an error?
bool$forceForce the rule to be applied, even if the target form element does not exist

◆ after_definition()

moodleform::after_definition ( )
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.

Return values
void

◆ closeHeaderBefore()

MoodleQuickForm::closeHeaderBefore ( $elementName)

Adds one or more element names that indicate the end of a fieldset.

Parameters
string$elementNamename of the element

◆ definition()

moodleform::definition ( )
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_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_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, 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_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_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.

◆ definition_after_data()

◆ display()

moodleform::display ( )

Print html form.

Reimplemented in base_moodleform, cohort_upload_form, and mod_feedback_complete_form.

◆ enable_form_change_checker()

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.

◆ exportValues()

MoodleQuickForm::exportValues ( $elementList = null)

export submitted values

Parameters
string$elementListlist of elements in form
Return values
array

◆ focus()

moodleform::focus ( $name = NULL)

To autofocus on first form element or first element with error.

Parameters
string$nameif this is set then the focus is forced to a field with this name
Return values
stringjavascript to select form element with first error or first element if no errors. Use this as a parameter when calling print_header

◆ form_init_date_js()

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

◆ get_array_value_by_keys()

moodleform::get_array_value_by_keys ( array $array,
array $keys )
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

Parameters
array$array
array$keys
Return values
mixedreturns null if keys not present

◆ get_data()

◆ get_draft_files()

moodleform::get_draft_files ( $elname)
protected

Get draft files of a form element This is a protected method which will be used only inside moodleforms.

Parameters
string$elnamename of element
Return values
array|bool|null

◆ get_file_content()

moodleform::get_file_content ( $elname)

Get content of uploaded file.

Parameters
string$elnamename of file upload element
Return values
string|boolfalse in case of failure, string if ok

◆ get_form_identifier()

moodleform::get_form_identifier ( )
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.

Return values
stringform identifier.

Reimplemented in enrol_self_enrol_form, and mod_assign_grade_form.

◆ get_js_module()

static moodleform::get_js_module ( )
static

Returns a JS module definition for the mforms JS.

Return values
array

Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.

◆ get_new_filename()

moodleform::get_new_filename ( $elname = null)

Returns name of uploaded file.

Parameters
string$elnamefirst element if null
Return values
string|boolfalse in case of failure, string if ok

◆ get_submitted_data()

moodleform::get_submitted_data ( )

Return submitted data without validation or NULL if there is no submitted data.

note: $slashed param removed

Return values
stdClass|nullsubmitted data; NULL if not submitted

Reimplemented in lesson_add_page_form_numerical.

◆ getAdvancedHTML()

MoodleQuickForm::getAdvancedHTML ( )

Returns HTML for advanced elements.

Return values
string

◆ getCleanedValue()

MoodleQuickForm::getCleanedValue ( $value,
$type )

Return the cleaned value using the passed type(s).

Parameters
mixed$valuevalue that has to be cleaned.
int | array$typeconstant value to use to clean (PARAM_...), typically returned by self::getCleanType().
Return values
mixedcleaned up value.

◆ getCleanType()

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).

Parameters
string$elementnamename of the element.
mixed$valuevalue that should be cleaned.
int$defaultdefault constant value to be returned (PARAM_...)
Return values
string|arrayconstant value or array of constant values (PARAM_...)

◆ getReqHTML()

MoodleQuickForm::getReqHTML ( )

Returns HTML for required elements.

Return values
string

◆ getShowAdvanced()

MoodleQuickForm::getShowAdvanced ( )

This function has been deprecated.

Show advanced has been replaced by "Show more.../Show less..." in the shortforms javascript module.

Deprecated
since Moodle 2.5
Return values
bool(Always false)

◆ getValidationScript()

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.

Return values
stringJavascript to perform validation, empty string if no 'client' rules were added

◆ init_javascript_enhancement()

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:

  • Selectboxes
    • smartselect: Turns a nbsp indented select box into a custom drop down control that supports multilevel and category selection. $enhancement = 'smartselect'; $options = array('selectablecategories' => true|false)
Parameters
string | element$elementform element for which Javascript needs to be initalized
string$enhancementwhich init function should be called
array$optionsoptions passed to javascript
array$stringsstrings for javascript
Deprecated
since Moodle 3.3 MDL-57471

◆ is_cancelled()

moodleform::is_cancelled ( )

Return true if a cancel button has been pressed resulting in the form being submitted.

Return values
booltrue if a cancel button has been pressed

Reimplemented in base_moodleform.

◆ is_dirty()

MoodleQuickForm::is_dirty ( )

Is the form currently set to dirty?

Return values
booleanInitial dirty state.
Since
Moodle 3.7.1

◆ is_form_change_checker_enabled()

MoodleQuickForm::is_form_change_checker_enabled ( )
Return values
boolwhether this form should automatically initialise formchangechecker for itself.

◆ is_submitted()

moodleform::is_submitted ( )

Check that form was submitted.

Does not check validity of submitted data.

Return values
booltrue if form properly submitted

◆ is_validated()

moodleform::is_validated ( )

Check that form data is valid.

You should almost always use this, rather than validate_defined_fields

Return values
booltrue if form data valid

◆ mock_ajax_submit()

static moodleform::mock_ajax_submit ( $simulatedsubmitteddata,
$simulatedsubmittedfiles = array(),
$method = 'post',
$formidentifier = null )
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.

Parameters
array$simulatedsubmitteddataAn associative array of form values (same format as $_POST).
array$simulatedsubmittedfilesAn associative array of files uploaded (same format as $_FILES). Can be omitted.
string$method'post' or 'get', defaults to 'post'.
null$formidentifierthe 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.
Return values
arrayarray 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.

◆ mock_generate_submit_keys()

static moodleform::mock_generate_submit_keys ( $data = [])
static

Used by tests to generate valid submit keys for moodle forms that are submitted with ajax data.

Exceptions
moodle_exceptionIf called outside unit test environment
Parameters
array$dataExisting form data you wish to add the keys to.
Return values
array

Reimplemented in feedback_edit_create_template_form, feedback_edit_use_template_form, and mod_feedback_use_templ_form.

◆ mock_submit()

static moodleform::mock_submit ( $simulatedsubmitteddata,
$simulatedsubmittedfiles = array(),
$method = 'post',
$formidentifier = null )
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.

Parameters
array$simulatedsubmitteddataAn associative array of form values (same format as $_POST).
array$simulatedsubmittedfilesAn associative array of files uploaded (same format as $_FILES). Can be omitted.
string$method'post' or 'get', defaults to 'post'.
null$formidentifierthe 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::moodleform ( $action = null,
$customdata = null,
$method = 'post',
$target = '',
$attributes = null,
$editable = true )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ MoodleQuickForm()

MoodleQuickForm::MoodleQuickForm ( $formName,
$method,
$action,
$target = '',
$attributes = null )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ no_submit_button_pressed()

moodleform::no_submit_button_pressed ( )

Checks if button pressed is not for submitting the form.

@staticvar bool $nosubmit keeps track of no submit button

Return values
bool

◆ optional_param() [1/2]

moodleform::optional_param ( $name,
$default,
$type )

Checks if a parameter was passed in the previous form submission.

Parameters
string$namethe name of the page parameter we want, for example 'id' or 'element[sub][13]'
mixed$defaultthe default value to return if nothing is found
string$typeexpected type of parameter
Return values
mixed

◆ optional_param() [2/2]

MoodleQuickForm::optional_param ( $name,
$default,
$type )

Checks if a parameter was passed in the previous form submission.

Parameters
string$namethe name of the page parameter we want
mixed$defaultthe default value to return if nothing is found
string$typeexpected type of parameter
Return values
mixed

◆ pear_handle_error()

pear_handle_error ( $error)

Callback called when PEAR throws an error.

Parameters
PEAR_Error$error

◆ prepare_fixed_value()

MoodleQuickForm::prepare_fixed_value ( $name,
$value )
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.)

Parameters
string$namethe element name.
mixed$valuethe fixed value to set.
Return values
mixedthe appropriate array to add to the $unfiltered array.

◆ render()

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.

Return values
stringHTML code for the form

◆ repeat_elements()

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.

Parameters
array$elementobjsArray of elements or groups of elements that are to be repeated
int$repeatsno of times to repeat elements initially
array$optionsa 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$repeathiddennamename for hidden element storing no of repeats in this form
string$addfieldsnamename for button to add more fields
int$addfieldsnohow many fields to add at a time
string$addstringname of button, {no} is replaced by no of blanks that will be added.
bool$addbuttoninsideif true, don't call closeHeaderBefore($addfieldsname). Default false.
string$deletebuttonnameif specified, treats the no-submit button with this name as a "delete element" button in each of the elements
Return values
intno of repeats of element in this page

◆ repeat_elements_fix_clone()

moodleform::repeat_elements_fix_clone ( $i,
$elementclone,
& $namecloned )

Helper used by repeat_elements().

Parameters
int$ithe index of this element.
HTML_QuickForm_element$elementclone
array$nameclonedarray of names

◆ save_file()

moodleform::save_file ( $elname,
$pathname,
$override = false )

Save file to standard filesystem.

Parameters
string$elnamename of element
string$pathnamefull path name of file
bool$overrideoverride file if exists
Return values
boolsuccess

◆ save_files()

moodleform::save_files ( $destination)

Save verified uploaded files into directory.

Upload process can be customised from definition()

Deprecated
since Moodle 2.0
Todo
MDL-31294 remove this api
See also
moodleform\save_stored_file()
moodleform\save_file()
Parameters
string$destinationpath where file should be stored
Return values
boolAlways false

◆ save_stored_file()

moodleform::save_stored_file ( $elname,
$newcontextid,
$newcomponent,
$newfilearea,
$newitemid,
$newfilepath = '/',
$newfilename = null,
$overwrite = false,
$newuserid = null )

Save file to local filesystem pool.

Parameters
string$elnamename of element
int$newcontextidid of context
string$newcomponentname of the component
string$newfileareaname of file area
int$newitemiditem id
string$newfilepathpath of file where it get stored
string$newfilenameuse specified filename, if not specified name of uploaded file used
bool$overwriteoverwrite file if exists
int$newuseridnew userid if required
Return values
mixedstored_file object or false if error; may throw exception if duplicate found

◆ save_temp_file()

moodleform::save_temp_file ( $elname)

Returns a temporary file, do not forget to delete after not needed any more.

Parameters
string$elnamename of the elmenet
Return values
string|booleither string or false

◆ set_data()

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

Parameters
stdClass | array$default_valuesobject 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.

◆ set_display_vertical()

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

◆ set_initial_dirty_state() [1/2]

moodleform::set_initial_dirty_state ( $state = false)

Set the initial 'dirty' state of the form.

Parameters
bool$state
Since
Moodle 3.7.1

◆ set_initial_dirty_state() [2/2]

MoodleQuickForm::set_initial_dirty_state ( $state = false)

Set the initial 'dirty' state of the form.

Parameters
bool$state
Since
Moodle 3.7.1

◆ setAdvanced()

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.

Parameters
string$elementNamegroup or element name (not the element name of something inside a group).
bool$advanceddefault true sets the element to advanced. False removes advanced mark.

◆ setConstant()

MoodleQuickForm::setConstant ( $elname,
$value )

Set constant value not overridden by _POST or _GET note: this does not work for complex names with [] :-(.

Parameters
string$elnamename of element
mixed$value

◆ setDefault()

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

Parameters
string$elementNameelement name
mixed$defaultValuevalues for that element name

◆ setDisableShortforms()

MoodleQuickForm::setDisableShortforms ( $disable = true)

Use this method to indicate that the form will not be using shortforms.

Parameters
boolean$disabledefault true, controls if the shortforms are disabled.

◆ setExpanded()

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.

Parameters
string$headernameheader element name
boolean$expandeddefault true sets the element to expanded. False makes the element collapsed.
boolean$ignoreuserstateoverride the state regardless of the state it was on when the form was submitted.
Return values
void

◆ setForceLtr()

MoodleQuickForm::setForceLtr ( $elementname,
$value = true )

◆ setShowAdvanced()

MoodleQuickForm::setShowAdvanced ( $showadvancedNow = null)

This function has been deprecated.

Show advanced has been replaced by "Show more.../Show less..." in the shortforms javascript module.

Deprecated
since Moodle 2.5
Parameters
bool$showadvancedNowif true will show advanced elements.

◆ setType()

MoodleQuickForm::setType ( $elementname,
$paramtype )

Should be used for all elements of a form except for select, radio and checkboxes which clean their own data.

Parameters
string$elementname
string$paramtypedefines type of data contained in element. Use the constants PARAM_*. lib/moodlelib.php for defined parameter types

◆ setTypes()

MoodleQuickForm::setTypes ( $paramtypes)

This can be used to set several types at once.

Parameters
array$paramtypestypes of parameters.
See also
MoodleQuickForm\setType

◆ updateSubmission()

MoodleQuickForm::updateSubmission ( $submission,
$files )

Updates submitted values.

Parameters
array$submissionsubmitted values
array$fileslist of files

◆ validate_defined_fields()

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,

Parameters
bool$validateonnosubmitoptional, 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
Return values
booltrue if form data valid

◆ validate_draft_files()

moodleform::validate_draft_files ( )
protected

Internal method.

Validates filepicker and filemanager files if they are set as required fields. Also, sets the error message if encountered one.

Return values
bool|arraywith errors

◆ validation()

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.

Parameters
array$dataarray of ("fieldname"=>value) of submitted data
array$filesarray of uploaded files "element_name"=>tmp_file_path
Return values
arrayof "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_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, 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_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_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_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.

Variable Documentation

◆ $_advancedElements

array MoodleQuickForm::$_advancedElements = array()

Array whose keys are element names.

If the key exists this is a advanced element

◆ $_collapsibleElements

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().

◆ $_pageparams

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.

◆ EDITOR_UNLIMITED_FILES

const EDITOR_UNLIMITED_FILES -1

setup.php includes our hacked pear libs first

EDITOR_UNLIMITED_FILES - hard-coded value for the 'maxfiles' option