/** * Prepare the configuration data for the moodle form. * * @return object */ public function prepare_data_for_form() { $data = $this->to_record(); foreach (configuration::get_defaultable_keys() as $key) { $data->{$key} = $this->get_config($key, configuration::get_default_value($key)); } return $data; }
/** * Add the specified step field configuration to the form. * * @param MoodleQuickForm $mform The form to add configuration to. * @param string $key The key to add. * @return $this */ public function add_config_field_to_form(\MoodleQuickForm $mform, $key) { $tour = $this->get_tour(); $default = (bool) $tour->get_config($key); $options = [true => get_string('yes'), false => get_string('no')]; if (!isset($options[$default])) { $default = configuration::get_default_value($key); } $options = array_reverse($options, true); $options[configuration::TOURDEFAULT] = get_string('defaultvalue', 'tool_usertours', $options[$default]); $options = array_reverse($options, true); $mform->addElement('select', $key, get_string($key, 'tool_usertours'), $options); $mform->setDefault($key, configuration::TOURDEFAULT); $mform->addHelpButton($key, $key, 'tool_usertours'); return $this; }