diff --git a/code/controllers/CMSPageAddController.php b/code/controllers/CMSPageAddController.php index ebe58020..09fbfb27 100644 --- a/code/controllers/CMSPageAddController.php +++ b/code/controllers/CMSPageAddController.php @@ -118,10 +118,17 @@ class CMSPageAddController extends CMSPageEditController { if(!SiteConfig::current_site_config()->canCreateTopLevel()) return Security::permissionFailure($this); } - + $record = $this->getNewItem("new-$className-$parentID".$suffix, false); if(class_exists('Translatable') && $record->hasExtension('Translatable')) $record->Locale = $data['Locale']; - $record->write(); + + try { + $record->write(); + } catch(ValidationException $ex) { + $form->sessionMessage($ex->getResult()->message(), 'bad'); + return $this->getResponseNegotiator()->respond($this->request); + } + $editController = singleton('CMSPageEditController'); $editController->setCurrentPageID($record->ID); diff --git a/templates/Includes/CMSPageAddController_Content.ss b/templates/Includes/CMSPageAddController_Content.ss index 1683921c..4457072c 100644 --- a/templates/Includes/CMSPageAddController_Content.ss +++ b/templates/Includes/CMSPageAddController_Content.ss @@ -1,37 +1,36 @@ -<% with AddForm %> -