Skip to content

Commit

Permalink
MDL-60569 registration: fix bug with showing email in the form
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Oct 25, 2017
1 parent 8494051 commit 13e7626
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions lib/classes/hub/site_registration_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ public function definition() {
$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);
}

Expand Down Expand Up @@ -212,26 +221,6 @@ protected function add_select_with_email($elementname, $stridentifier, $options

}

/**
* 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
*
Expand Down

0 comments on commit 13e7626

Please sign in to comment.