How to get block configuration values

How to get block configuration values

by Zoran Jeremic -
Number of replies: 2

Hi,

I'm trying to catch some values stored in block configuration so I can store it in the database as separate and make available out of block configuration.

I added form element in

protected function specific_definition($mform) {
....
$defaults = array('yes'=>'yes', 'no'=>'no');
$mform->addElement('select', 'config_studentmobileaccess', get_string('studentsmobileaccess', 'block_morph'), $defaults);
$mform->setDefault('config_studentmobileaccess', 'default');

I tried to overload function set_data like this

function set_data($defaults) {
parent::set_data($defaults);
$val1=$defaults->config_studentmobileaccess
$val2=json_encode($this->block->config)


Both values val1 and val2 shows reads old values from the form. Could somebody explain how to get new values inserted into the form?


Thanks,

Zoran

Average of ratings: -
In reply to Zoran Jeremic

Re: How to get block configuration values

by Darko Miletić -

Defaults are one thing and values are something else. You can have a text field with default set to one value and user can enter something different which would change the value.

So if you are looking for a submitted value you can use:

$fieldvalue = $this->_form->getSubmitValue('fieldname');


Of course if you had something else in mind please clarify.

Average of ratings: Useful (2)