diff --git a/code/GridFieldAddNewMultiClass.php b/code/GridFieldAddNewMultiClass.php index e2d4b7b..d0983e1 100755 --- a/code/GridFieldAddNewMultiClass.php +++ b/code/GridFieldAddNewMultiClass.php @@ -129,8 +129,15 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL throw new SS_HTTPResponse_Exception(400); } + $record = new $class(); + $List = $grid->getList(); + if ($List && $List->is_a('HasManyList')) { + $fk = $List->getForeignKey(); + $record->$fk = $List->getForeignID(); + } + $handler = new GridFieldAddNewMultiClassHandler( - $grid, $component, new $class(), $grid->getForm()->getController(), 'add-multi-class' + $grid, $component, $record, $grid->getForm()->getController(), 'add-multi-class' ); $handler->setTemplate($component->getTemplate());