mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
[Fix] (Squash) CMSMain::save class change
Fixed class change as it was treating ClassName attrs in reverse order (going new->to->old, rather than old->to->new).
This commit is contained in:
parent
f7a0ec395a
commit
be348af3eb
@ -972,12 +972,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
// Update the class instance if necessary
|
// Update the class instance if necessary
|
||||||
if(isset($data['ClassName']) && $data['ClassName'] != $record->ClassName) {
|
if(isset($data['ClassName']) && $data['ClassName'] != $record->ClassName) {
|
||||||
$newClassName = $record->ClassName;
|
// Replace $record with a new instance of the new class
|
||||||
// The records originally saved attribute was overwritten by $form->saveInto($record) before.
|
$newClassName = $data['ClassName'];
|
||||||
// This is necessary for newClassInstance() to work as expected, and trigger change detection
|
|
||||||
// on the ClassName attribute
|
|
||||||
$record->setClassName($data['ClassName']);
|
|
||||||
// Replace $record with a new instance
|
|
||||||
$record = $record->newClassInstance($newClassName);
|
$record = $record->newClassInstance($newClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user