From ec41cb38ce33444e440109ddda0418175c043ff8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 30 Nov 2013 14:12:19 +0100 Subject: [PATCH] ValidationException support in CMS "Settings" UI --- code/controllers/CMSSettingsController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index a86ad860..beec22fd 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -77,7 +77,13 @@ class CMSSettingsController extends LeftAndMain { public function save_siteconfig($data, $form) { $siteConfig = SiteConfig::current_site_config(); $form->saveInto($siteConfig); - $siteConfig->write(); + + try { + $siteConfig->write(); + } catch(ValidationException $ex) { + $form->sessionMessage($ex->getResult()->message(), 'bad'); + return $this->getResponseNegotiator()->respond($this->request); + } $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.'))); return $this->getResponseNegotiator()->respond($this->request);