From 6818ed1908e0ccc640642910dd3f7b54e950ad8a Mon Sep 17 00:00:00 2001 From: Malte Jansen Date: Thu, 5 Dec 2013 11:52:38 +0100 Subject: [PATCH] Adding RelationData (HasManyList) into record to generate FormFields. So Relations on new data object are available in getCMSFields() --- code/GridFieldAddNewMultiClass.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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());