Commit 13e76268 authored by Marina Glancy's avatar Marina Glancy
Browse files

MDL-60569 registration: fix bug with showing email in the form

parent 84940517
......@@ -173,6 +173,15 @@ class site_registration_form extends \moodleform {
$mform->addElement('hidden', 'returnurl');
$mform->setType('returnurl', PARAM_LOCALURL);
// Prepare and set data.
$siteinfo['emailalertnewemail'] = !empty($siteinfo['emailalert']) && !empty($siteinfo['emailalertemail']);
if (empty($siteinfo['emailalertnewemail'])) {
$siteinfo['emailalertemail'] = '';
}
$siteinfo['commnewsnewemail'] = !empty($siteinfo['commnews']) && !empty($siteinfo['commnewsemail']);
if (empty($siteinfo['commnewsnewemail'])) {
$siteinfo['commnewsemail'] = '';
}
$this->set_data($siteinfo);
}
......@@ -212,26 +221,6 @@ class site_registration_form extends \moodleform {
}
/**
* Load in existing data as form defaults
*
* @param stdClass|array $defaultvalues object or array of default values
*/
public function set_data($defaultvalues) {
if (is_object($defaultvalues)) {
$defaultvalues = (array)$defaultvalues;
}
$defaultvalues['emailalertnewemail'] = !empty($defaultvalues['emailalert']) && !empty($defaultvalues['emailalertemail']);
if (empty($defaultvalues['emailalertnewemail'])) {
$defaultvalues['emailalertemail'] = '';
}
$defaultvalues['commnewsnewemail'] = !empty($defaultvalues['commnews']) && !empty($defaultvalues['commnewsemail']);
if (empty($defaultvalues['commnewsnewemail'])) {
$defaultvalues['commnewsemail'] = '';
}
parent::set_data($defaultvalues);
}
/**
* Validation of the form data
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment