mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Using try/catch blocks in ComplexTableField->saveComplexTableField() to catch any ValidationExceptions and terminate the saving process
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78255 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c542ec0de9
commit
da758f9f6e
@ -202,7 +202,6 @@ class ComplexTableField extends TableListField {
|
||||
$this->pageSize = 10;
|
||||
|
||||
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -625,7 +624,13 @@ JS;
|
||||
$className = $this->sourceClass();
|
||||
$childData = new $className();
|
||||
$form->saveInto($childData);
|
||||
$childData->write();
|
||||
|
||||
try {
|
||||
$childData->write();
|
||||
} catch(ValidationException $e) {
|
||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
||||
return Director::redirectBack();
|
||||
}
|
||||
|
||||
// Save the many many relationship if it's available
|
||||
if(isset($data['ctf']['manyManyRelation'])) {
|
||||
@ -796,7 +801,13 @@ class ComplexTableField_ItemRequest extends RequestHandler {
|
||||
function saveComplexTableField($data, $form, $request) {
|
||||
$dataObject = $this->dataObj();
|
||||
$form->saveInto($dataObject);
|
||||
$dataObject->write();
|
||||
|
||||
try {
|
||||
$dataObject->write();
|
||||
} catch(ValidationException $e) {
|
||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
||||
return Director::redirectBack();
|
||||
}
|
||||
|
||||
// Save the many many relationship if it's available
|
||||
if(isset($data['ctf']['manyManyRelation'])) {
|
||||
|
Loading…
Reference in New Issue
Block a user