mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Form now loads correctly when ClassName is changed.
This commit is contained in:
parent
c08ab18c03
commit
5143c8149a
@ -455,6 +455,16 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
||||
if(!$this->record->canEdit()) {
|
||||
return $controller->httpError(403);
|
||||
}
|
||||
|
||||
if (isset($data['ClassName']) && $data['ClassName'] != $this->record->ClassName) {
|
||||
$newClassName = $data['ClassName'];
|
||||
// The records originally saved attribute was overwritten by $form->saveInto($record) before.
|
||||
// This is necessary for newClassInstance() to work as expected, and trigger change detection
|
||||
// on the ClassName attribute
|
||||
$this->record->setClassName($this->record->ClassName);
|
||||
// Replace $record with a new instance
|
||||
$this->record = $this->record->newClassInstance($newClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
$form->saveInto($this->record);
|
||||
|
Loading…
x
Reference in New Issue
Block a user