See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
Customfield component data controller abstract class
Copyright: | 2018 Toni Barbera <toni@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 371 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
data_controller:: (19 methods):
__construct()
create()
get_form_element_name()
get()
set()
delete()
save()
get_field()
instance_form_save()
instance_form_before_set_data()
is_empty()
is_unique()
instance_form_validation()
instance_form_definition_after_data()
display()
get_value()
get_context()
export_value()
to_record()
Class: data_controller - X-Ref
Base class for custom fields data controllers__construct(int $id, \stdClass $record) X-Ref |
data_controller constructor. param: int $id param: \stdClass|null $record |
create(int $id, \stdClass $record = null, field_controller $field = null) X-Ref |
Creates an instance of data_controller Parameters $id, $record and $field can complement each other but not conflict. If $id is not specified, fieldid must be present either in $record or in $field. If $id is not specified, instanceid must be present in $record No DB queries are performed if both $record and $field are specified. param: int $id param: \stdClass|null $record param: field_controller|null $field return: data_controller |
get_form_element_name() X-Ref |
Returns the name of the field to be used on HTML forms. return: string |
get($property) X-Ref |
Persistent getter parser. param: string $property return: mixed |
set($property, $value) X-Ref |
Persistent setter parser. param: string $property param: mixed $value return: data |
delete() X-Ref |
Delete data. Element can override it if related information needs to be deleted as well (such as files) return: bool |
save() X-Ref |
Persistent save parser. return: void |
get_field() X-Ref |
Field associated with this data return: field_controller |
instance_form_save(\stdClass $datanew) X-Ref |
Saves the data coming from form param: \stdClass $datanew data coming from the form |
instance_form_before_set_data(\stdClass $instance) X-Ref |
Prepares the custom field data related to the object to pass to mform->set_data() and adds them to it This function must be called before calling $form->set_data($object); param: \stdClass $instance the instance that has custom fields, if 'id' attribute is present the custom |
is_empty($value) X-Ref |
Checks if the value is empty param: mixed $value return: bool |
is_unique($value) X-Ref |
Checks if the value is unique param: mixed $value return: bool |
instance_form_validation(array $data, array $files) X-Ref |
Called from instance edit form in validation() param: array $data param: array $files return: array array of errors |
instance_form_definition_after_data(\MoodleQuickForm $mform) X-Ref |
Called from instance edit form in definition_after_data() param: \MoodleQuickForm $mform |
display() X-Ref |
Used by handlers to display data on various places. return: string |
get_value() X-Ref |
Returns the value as it is stored in the database or default value if data record is not present return: mixed |
get_context() X-Ref |
Return the context of the field return: \context |
export_value() X-Ref |
Returns value in a human-readable format or default value if data record is not present This is the default implementation that most likely needs to be overridden return: mixed|null value or null if empty |
to_record() X-Ref |
Persistent to_record parser. return: \stdClass |