FIX UserFormFieldEditorExtension::onAfterDuplicate accepts the correct parameters from DataObject::duplicate

This commit is contained in:
Robbie Averill 2017-08-16 12:14:46 +12:00
parent 1bd0b0c138
commit f25f1e9c1b

View File

@ -213,19 +213,19 @@ class UserFormFieldEditorExtension extends DataExtension
* When duplicating a UserDefinedForm, duplicate all of its fields and display rules
*
* @see DataObject::duplicate
* @param DataObject $newPage
* @param DataObject $oldPage
* @param bool $doWrite
* @param string $manyMany
* @return DataObject
*/
public function onAfterDuplicate($newPage, $doWrite, $manyMany)
public function onAfterDuplicate($oldPage, $doWrite, $manyMany)
{
// List of EditableFieldGroups, where the key of the array is the ID of the old end group
$fieldGroups = [];
foreach ($this->owner->Fields() as $field) {
foreach ($oldPage->Fields() as $field) {
$newField = $field->duplicate(false);
$newField->ParentID = $newPage->ID;
$newField->ParentClass = $newPage->ClassName;
$newField->ParentID = $this->owner->ID;
$newField->ParentClass = $this->owner->ClassName;
$newField->Version = 0;
$newField->write();
@ -248,8 +248,6 @@ class UserFormFieldEditorExtension extends DataExtension
$newRule->write();
}
}
return $newPage;
}
/**