mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Less intrusive doSave() overwrite of GridFieldDetailForm
Fixes issues with valiation errors not showing due to lack of PjaxResponseNegotiator support (parent implementation has changed).
This commit is contained in:
parent
0e9c3344ac
commit
6a9003e8df
@ -40,7 +40,6 @@ class GridFieldSubsiteDetailForm_ItemRequest extends GridFieldDetailForm_ItemReq
|
|||||||
|
|
||||||
function doSave($data, $form) {
|
function doSave($data, $form) {
|
||||||
$new_record = $this->record->ID == 0;
|
$new_record = $this->record->ID == 0;
|
||||||
|
|
||||||
if($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) {
|
if($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) {
|
||||||
$template = Subsite::get()->byID(intval($data['TemplateID']));
|
$template = Subsite::get()->byID(intval($data['TemplateID']));
|
||||||
if($template) {
|
if($template) {
|
||||||
@ -48,25 +47,6 @@ class GridFieldSubsiteDetailForm_ItemRequest extends GridFieldDetailForm_ItemReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return parent::doSave($data, $form);
|
||||||
$form->saveInto($this->record);
|
|
||||||
$this->record->write();
|
|
||||||
$this->gridField->getList()->add($this->record);
|
|
||||||
} catch(ValidationException $e) {
|
|
||||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
|
||||||
return Controller::curr()->redirectBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Save this item into the given relationship
|
|
||||||
|
|
||||||
$message = sprintf(
|
|
||||||
_t('GridFieldDetailForm.Saved', 'Saved %s %s'),
|
|
||||||
$this->record->singular_name(),
|
|
||||||
'<a href="' . $this->Link('edit') . '">"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"</a>'
|
|
||||||
);
|
|
||||||
|
|
||||||
$form->sessionMessage($message, 'good');
|
|
||||||
|
|
||||||
return Controller::curr()->redirect($this->Link());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user