mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX: Catch and display validation errors when adding a page.
This commit is contained in:
parent
098d3b6b8a
commit
cdea489fcb
@ -121,7 +121,14 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
|
|
||||||
$record = $this->getNewItem("new-$className-$parentID".$suffix, false);
|
$record = $this->getNewItem("new-$className-$parentID".$suffix, false);
|
||||||
if(class_exists('Translatable') && $record->hasExtension('Translatable')) $record->Locale = $data['Locale'];
|
if(class_exists('Translatable') && $record->hasExtension('Translatable')) $record->Locale = $data['Locale'];
|
||||||
|
|
||||||
|
try {
|
||||||
$record->write();
|
$record->write();
|
||||||
|
} catch(ValidationException $ex) {
|
||||||
|
$form->sessionMessage($ex->getResult()->message(), 'bad');
|
||||||
|
return $this->getResponseNegotiator()->respond($this->request);
|
||||||
|
}
|
||||||
|
|
||||||
$editController = singleton('CMSPageEditController');
|
$editController = singleton('CMSPageEditController');
|
||||||
$editController->setCurrentPageID($record->ID);
|
$editController->setCurrentPageID($record->ID);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
<div class="cms-content center $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content">
|
||||||
<% with AddForm %>
|
<% with AddForm %>
|
||||||
<form $FormAttributes data-layout-type="border">
|
<form $FormAttributes data-layout-type="border">
|
||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<div class="cms-content-header-info">
|
<div class="cms-content-header-info">
|
||||||
<h2><% _t('CMSAddPageController.Title','Add page') %></h2>
|
<h2><% _t('CMSAddPageController.Title','Add page') %></h2>
|
||||||
@ -8,7 +8,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-content-fields center cms-panel-content cms-panel-padded">
|
<div class="cms-content-fields center cms-panel-content cms-panel-padded">
|
||||||
|
|
||||||
<% if Message %>
|
<% if Message %>
|
||||||
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
@ -32,6 +31,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<% end_with %>
|
<% end_with %>
|
||||||
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user