Skip to content
Snippets Groups Projects
Commit 4866834c authored by Tim Repke's avatar Tim Repke
Browse files

fix updating bachelor via admin

parent c420dd48
No related branches found
No related tags found
No related merge requests found
......@@ -7,9 +7,12 @@ class AdminListPage extends AdminPage {
if (isset($_REQUEST['change'])) {
try {
$b = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$b->set(['bachelor_id' => $_REQUEST['change']]);
$saveResult = $b->save();
$bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$bNew->set(['bachelor_id' => $_REQUEST['change']]);
$bOld = Bachelor::makeFromDB($this->fahrt, $_REQUEST['change']);
$bOld->updateBachelor($bNew);
$saveResult = $bOld->save();
if ($saveResult !== Bachelor::SAVE_SUCCESS)
throw new Exception('Fehler beim Speichern mit code ' . $saveResult.'<br />'.implode('<br />', $b->getValidationErrors()));
else
......
......@@ -459,4 +459,15 @@ class Bachelor {
}
}
/**
* @param $newBachelor Bachelor
*/
public function updateBachelor($newBachelor) {
$nBdata = $newBachelor->getData();
foreach ($this->data as $key => $val) {
if (isset($nBdata[$key]) and !empty($nBdata[$key]))
$this->data[$key] = $nBdata[$key];
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment