Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

Menu profile field.

Copyright: 2007 onwards Shane Elliot {@link http://pukunui.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 173 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: profile_field_menu  - X-Ref

Class profile_field_menu

__construct($fieldid = 0, $userid = 0, $fielddata = null)   X-Ref
Constructor method.

Pulls out the options for the menu from the database and sets the the corresponding key for the data if it exists.

param: int $fieldid
param: int $userid
param: object $fielddata

edit_field_add($mform)   X-Ref
Create the code snippet for this field instance
Overwrites the base class method

param: moodleform $mform Moodle form instance

edit_field_set_default($mform)   X-Ref
Set the default value for this field instance
Overwrites the base class method.

param: moodleform $mform Moodle form instance

edit_save_data_preprocess($data, $datarecord)   X-Ref
The data from the form returns the key.

This should be converted to the respective option string to be saved in database
Overwrites base class accessor method.

param: mixed $data The key returned from the select input in the form
param: stdClass $datarecord The object that will be used to save the record
return: mixed Data or null

edit_load_user_data($user)   X-Ref
When passing the user object to the form class for the edit profile page
we should load the key for the saved data

Overwrites the base class method.

param: stdClass $user User object.

edit_field_set_locked($mform)   X-Ref
HardFreeze the field if locked.

param: moodleform $mform instance of the moodleform class

convert_external_data($value)   X-Ref
Convert external data (csv file) from value to key for processing later by edit_save_data_preprocess

param: string $value one of the values in menu options.
return: int options key for the menu

get_field_properties()   X-Ref
Return the field type and null properties.
This will be used for validating the data submitted by a user.

return: array the param type and null property