diff --git a/blocks/HOWTO.html b/blocks/HOWTO.html index 640c5210bdd..6482e46ba80 100644 --- a/blocks/HOWTO.html +++ b/blocks/HOWTO.html @@ -816,6 +816,8 @@ function instance_config_save($data) {
Note that $data does not hold all of the submitted POST data because Moodle adds some hidden fields to the form in order to be able to process it. However, before calling this method it strips the hidden fields from the received data and so when this method is called only the "real" configuration data remain.
+If you want to update the stored copy of the configuration data at run time (for example to persist some changes you made programmatically), you should not use this method. The correct procedure for that purpose is to call instance_config_commit.
+You should return a boolean value denoting the success or failure of your method's actions.
@@ -876,6 +878,17 @@ function specialization() {
+function instance_config_commit() {
+ return set_field('block_instance',
+ 'configdata', base64_encode(serialize($this->config)),
+ 'id', $this->instance->id);
+}
+
+ This method saves the current contents of $this->config to the database. If you need to make a change to the configuration settings of a block instance at run time (and not through the usual avenue of letting the user change it), just make the changes you want to $this->config and then call this method.
+
@@ -966,7 +979,7 @@ function name() {
The variable is initialized just after the block object is constructed, immediately before specialization is called for the object. It is possible that the block has no instance configuration, in which case the variable will be NULL.
- It is obvious that there is a direct relationship between this variable and the configdata field in the mdl_block_instance table. However, it is strongly advised that you refrain from acessing the configdata field yourself. If you absolutely must update its value at any time, it is recommended that you call the method instance_config_save to do the actual work.
+ It is obvious that there is a direct relationship between this variable and the configdata field in the mdl_block_instance table. However, it is strongly advised that you refrain from accessing the configdata field yourself. If you absolutely must update its value at any time, it is recommended that you call the method instance_config_commit to do the actual work.